-
Notifications
You must be signed in to change notification settings - Fork 209
Expand file tree
/
Copy pathoption_test.go
More file actions
33 lines (30 loc) · 962 Bytes
/
Copy pathoption_test.go
File metadata and controls
33 lines (30 loc) · 962 Bytes
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
package cmdutil
import (
"testing"
"github.com/google/go-cmp/cmp"
)
func TestPickOption(t *testing.T) {
tests := []struct {
args []string
opts []string
want string
wantRemains []string
}{
{[]string{}, []string{}, "", []string{}},
{[]string{"-a", "-b", "B", "-c"}, []string{"-b"}, "B", []string{"-a", "-c"}},
{[]string{"-a", "-b=B", "-c"}, []string{"-b"}, "B", []string{"-a", "-c"}},
{[]string{"-a", "-b=B", "-c"}, []string{"-b", "--bbb"}, "B", []string{"-a", "-c"}},
{[]string{"-a", "-b=B", "-c"}, []string{"-d"}, "", []string{"-a", "-b=B", "-c"}},
{[]string{"-b=B"}, []string{"-b"}, "B", []string{}},
{[]string{"-b", "B"}, []string{"-b"}, "B", []string{}},
}
for _, tt := range tests {
got, gotRemains := PickOption(tt.args, tt.opts)
if got != tt.want {
t.Errorf("got %v\nwant %v", got, tt.want)
}
if diff := cmp.Diff(gotRemains, tt.wantRemains, nil); diff != "" {
t.Errorf("%s", diff)
}
}
}