37 lines
743 B
Go
37 lines
743 B
Go
package cli
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
"testing"
|
|
)
|
|
|
|
func TestCliStartServiceDefinitionPathMustExist(t *testing.T) {
|
|
cli := GetCli()
|
|
|
|
cli.SetArgs([]string{"start", "-d", "./not-a-file.yml"})
|
|
|
|
outcome := cli.Execute()
|
|
|
|
if outcome == nil {
|
|
t.Errorf("Expected error, got nil.")
|
|
}
|
|
}
|
|
|
|
func TestCliStartDefaultsServiceDefinitionPath(t *testing.T) {
|
|
cli := GetCli()
|
|
|
|
cli.SetArgs([]string{"start"})
|
|
|
|
startCommand, _, _ := cli.Find([]string{"start"})
|
|
|
|
startCommand.RunE = func(cmd *cobra.Command, args []string) error {
|
|
actual, _ := cmd.PersistentFlags().GetString("definition")
|
|
if actual != "./service.yml" {
|
|
t.Errorf("Unexpected default value for 'definition' / 'd' arg: %s", actual)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
cli.Execute()
|
|
}
|