github.com/scaleway/scaleway-cli@v1.11.1/pkg/cli/run_test.go (about)

     1  package cli
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	. "github.com/smartystreets/goconvey/convey"
     8  )
     9  
    10  func TestRunRun(t *testing.T) {
    11  	Convey("Testing runRun", t, func() {
    12  		cmdRun.Flag.Parse([]string{"-a", "-d"})
    13  		rawArgs := []string{"my-server"}
    14  		So(runRun(cmdRun, rawArgs), ShouldResemble, fmt.Errorf("conflicting options: -a and -d"))
    15  		runAttachFlag = false
    16  		runDetachFlag = false
    17  
    18  		cmdRun.Flag.Parse([]string{"-a"})
    19  		rawArgs = []string{"my-server", "my-command"}
    20  		So(runRun(cmdRun, rawArgs), ShouldResemble, fmt.Errorf("conflicting options: -a and COMMAND"))
    21  		runAttachFlag = false
    22  
    23  		cmdRun.Flag.Parse([]string{"-d"})
    24  		rawArgs = []string{"my-server", "my-command"}
    25  		So(runRun(cmdRun, rawArgs), ShouldResemble, fmt.Errorf("conflicting options: -d and COMMAND"))
    26  		runDetachFlag = false
    27  
    28  		cmdRun.Flag.Parse([]string{"-d", "--rm"})
    29  		rawArgs = []string{"my-server"}
    30  		So(runRun(cmdRun, rawArgs), ShouldResemble, fmt.Errorf("conflicting options: --detach and --rm"))
    31  	})
    32  }