q/src/cli/Main_test.go

42 lines
1.2 KiB
Go

package cli_test
import (
"testing"
"git.urbach.dev/cli/q/src/cli"
"git.urbach.dev/cli/q/src/config"
"git.urbach.dev/go/assert"
)
func TestCLI(t *testing.T) {
type cliTest struct {
arguments []string
expectedExitCode int
}
tests := []cliTest{
{[]string{}, 2},
{[]string{"invalid"}, 2},
{[]string{"help"}, 0},
{[]string{"system"}, 0},
{[]string{"build", "invalid-directory"}, 1},
{[]string{"build", "--invalid-parameter"}, 2},
{[]string{"build", "../../examples/hello", "--invalid"}, 2},
{[]string{"build", "../../examples/hello", "--dry"}, 0},
{[]string{"build", "../../examples/hello", "--dry", "--verbose"}, 0},
{[]string{"build", "../../examples/hello", "--dry", "--os", "linux"}, 0},
{[]string{"build", "../../examples/hello", "--dry", "--os", "mac"}, 0},
{[]string{"build", "../../examples/hello", "--dry", "--os", "windows"}, 0},
{[]string{"build", "../../examples/hello/hello.q", "--dry"}, 0},
{[]string{"build", "../../examples/hello"}, 0},
{[]string{"run", "../../examples/hello", "--invalid"}, 2},
{[]string{"run", "../../examples/hello"}, 0},
}
for _, test := range tests {
t.Log(test.arguments)
config.Reset()
exitCode := cli.Main(test.arguments)
assert.Equal(t, exitCode, test.expectedExitCode)
}
}