-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathservicenow_service_client_config_test.go
53 lines (47 loc) · 1.37 KB
/
servicenow_service_client_config_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
package servicenowsdkgo
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
func TestBuildServiceClientConfig(t *testing.T) {
tests := []struct {
name string
test func(*testing.T)
}{
{
name: "successful",
test: func(t *testing.T) {
strct := newMockServiceNowClientOption()
strct.On("ServiceNowServiceClientOption", mock.IsType(&serviceNowServiceClientConfig{})).Return(nil)
option := strct.ServiceNowServiceClientOption
config, err := buildServiceClientConfig(option)
assert.Nil(t, err)
assert.NotNil(t, config)
},
},
{
name: "option error",
test: func(t *testing.T) {
strct := newMockServiceNowClientOption()
strct.On("ServiceNowServiceClientOption", mock.IsType(&serviceNowServiceClientConfig{})).Return(errors.New("option error"))
option := strct.ServiceNowServiceClientOption
config, err := buildServiceClientConfig(option)
assert.Equal(t, errors.New("option error"), err)
assert.Nil(t, config)
},
},
{
name: "instance and raw uri",
test: func(t *testing.T) {
config, err := buildServiceClientConfig(withInstance("fdasfsda"), withURL("https://dafsfd.com"))
assert.Equal(t, errors.New("rawURL and instance cannot be used together"), err)
assert.Nil(t, config)
},
},
}
for _, test := range tests {
t.Run(test.name, test.test)
}
}