31 lines
615 B
Go
Raw Normal View History

2023-10-17 12:01:01 +00:00
package main_test
import (
"testing"
"git.akyoto.dev/cli/q/cli"
"git.akyoto.dev/go/assert"
)
func TestCLI(t *testing.T) {
type cliTest struct {
arguments []string
expectedExitCode int
}
tests := []cliTest{
2023-10-17 13:10:35 +00:00
{[]string{}, 2},
{[]string{"invalid"}, 2},
2023-10-17 12:01:01 +00:00
{[]string{"system"}, 0},
2023-10-17 13:10:35 +00:00
{[]string{"build", "non-existing-directory"}, 1},
{[]string{"build", "examples/hello/hello.q"}, 2},
{[]string{"build", "examples/hello", "--invalid"}, 2},
2023-10-17 12:01:01 +00:00
}
for _, test := range tests {
exitCode := cli.Main(test.arguments)
t.Log(test.arguments)
assert.Equal(t, exitCode, test.expectedExitCode)
}
}