-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
42 lines (40 loc) · 804 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"os"
"reflect"
"testing"
)
func Test_parseArgs(t *testing.T) {
tests := []struct {
in []string
cmd string
args []string
}{
{
[]string{"sqlpkg"},
"", nil,
},
{
[]string{"sqlpkg", "help"},
"help", []string{},
},
{
[]string{"sqlpkg", "install", "nalgeon/example"},
"install", []string{"nalgeon/example"},
},
{
[]string{"sqlpkg", "-v", "install", "nalgeon/example"},
"install", []string{"nalgeon/example"},
},
}
for _, test := range tests {
os.Args = test.in
cmd, args := parseArgs()
if cmd != test.cmd {
t.Errorf("parseArgs(%v) expected cmd = %s, got %s", test.in, test.cmd, cmd)
}
if !reflect.DeepEqual(args, test.args) {
t.Errorf("parseArgs(%v) expected args = %v, got %v", test.in, test.args, args)
}
}
}