forked from gocardless/gocardless-pro-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options_test.go
52 lines (45 loc) · 1.03 KB
/
options_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
package gocardless
import "testing"
func TestEndpointForToken(t *testing.T) {
tests := []struct {
token string
wantErr bool
}{
{"", true},
{"dummy_token", false},
}
for _, tt := range tests {
_, err := NewConfig(tt.token)
if tt.wantErr {
if err == nil {
t.Fatalf("expected error if token is invalid, got nil for token: %v", tt.token)
}
continue
}
if err != nil {
t.Fatalf("unexepcted error if token is valid, got token: %v, err: %v", tt.token, err)
}
}
}
func TestEndpointForConfig(t *testing.T) {
tests := []struct {
endpoint string
wantErr bool
}{
{"http://foo.com", false},
{"1http://foo.com", true},
}
for _, tt := range tests {
token := "dummy_token"
_, err := NewConfig(token, WithEndpoint(tt.endpoint))
if tt.wantErr {
if err == nil {
t.Fatalf("expected error if endpoint is invalid, got nil for endpoint: %v", tt.endpoint)
}
continue
}
if err != nil {
t.Fatalf("unexepcted error if endpoint is valid, got endpoint: %v, err: %v", tt.endpoint, err)
}
}
}