-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain_test.go
55 lines (50 loc) · 941 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
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"strings"
"testing"
"github.com/cloud-gov/cf-service-connect/connector"
"github.com/stretchr/testify/assert"
)
type parseOptionsTest struct {
args string
expectError bool
expectedOptions connector.Options
}
func TestParseOptions(t *testing.T) {
tests := []parseOptionsTest{
{
"connect-to-service app service",
false,
connector.Options{
"app",
"service",
true,
},
},
{
"connect-to-service -no-client app service",
false,
connector.Options{
"app",
"service",
false,
},
},
{
"connect-to-service foo bar baz",
true,
connector.Options{},
},
}
plugin := ServiceConnectPlugin{}
for _, test := range tests {
args := strings.Split(test.args, " ")
opts, err := plugin.parseOptions(args)
if test.expectError {
assert.NotNil(t, err)
} else {
assert.Nil(t, err)
assert.Equal(t, opts, test.expectedOptions)
}
}
}