-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_fake_test.go
68 lines (64 loc) · 1.22 KB
/
client_fake_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
56
57
58
59
60
61
62
63
64
65
66
67
68
package modzy
import (
"testing"
)
func TestClientFake(t *testing.T) {
calls := 0
fake := &ClientFake{
WithAPIKeyFunc: func(apiKey string) Client {
if apiKey != "apiKey" {
t.Error("apiKey not passed through")
}
calls++
return nil
},
WithTeamKeyFunc: func(teamID string, token string) Client {
if teamID != "teamID" {
t.Error("teamID not passed through")
}
if token != "token" {
t.Error("token not passed through")
}
calls++
return nil
},
WithOptionsFunc: func(opts ...ClientOption) Client {
if len(opts) != 2 {
t.Errorf("did not pass through options")
}
calls++
return nil
},
AccountingFunc: func() AccountingClient {
calls++
return nil
},
JobsFunc: func() JobsClient {
calls++
return nil
},
ModelsFunc: func() ModelsClient {
calls++
return nil
},
DashboardFunc: func() DashboardClient {
calls++
return nil
},
ResourcesFunc: func() ResourcesClient {
calls++
return nil
},
}
fake.WithAPIKey("apiKey")
fake.WithTeamKey("teamID", "token")
fake.WithOptions(nil, nil)
fake.Accounting()
fake.Jobs()
fake.Models()
fake.Dashboard()
fake.Resources()
if calls != 8 {
t.Errorf("Did not call all of the funcs: %d", calls)
}
}