-
Notifications
You must be signed in to change notification settings - Fork 1
/
accounting_client_fake_test.go
80 lines (75 loc) · 2.05 KB
/
accounting_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
69
70
71
72
73
74
75
76
77
78
79
80
// nolint:errcheck
package modzy
import (
"context"
"testing"
)
func TestAccountingClientFake(t *testing.T) {
expectedCtx := context.WithValue(context.TODO(), testContextKey("a"), "b")
calls := 0
fake := &AccountingClientFake{
GetEntitlementsFunc: func(ctx context.Context) (*GetEntitlementsOutput, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
return nil, nil
},
HasEntitlementFunc: func(ctx context.Context, entitlement string) (bool, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
if entitlement != "entitlement" {
t.Errorf("input was not passed through")
}
return false, nil
},
GetLicenseFunc: func(ctx context.Context) (*GetLicenseOutput, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
return nil, nil
},
ListAccountingUsersFunc: func(ctx context.Context, input *ListAccountingUsersInput) (*ListAccountingUsersOutput, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
if input == nil {
t.Errorf("input was not passed through")
}
return nil, nil
},
ListProjectsFunc: func(ctx context.Context, input *ListProjectsInput) (*ListProjectsOutput, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
if input == nil {
t.Errorf("input was not passed through")
}
return nil, nil
},
GetProjectDetailsFunc: func(ctx context.Context, input *GetProjectDetailsInput) (*GetProjectDetailsOutput, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
if input == nil {
t.Errorf("input was not passed through")
}
return nil, nil
},
}
fake.GetEntitlements(expectedCtx)
fake.HasEntitlement(expectedCtx, "entitlement")
fake.GetLicense(expectedCtx)
fake.ListAccountingUsers(expectedCtx, &ListAccountingUsersInput{})
fake.ListProjects(expectedCtx, &ListProjectsInput{})
fake.GetProjectDetails(expectedCtx, &GetProjectDetailsInput{})
if calls != 6 {
t.Errorf("Did not call all of the funcs: %d", calls)
}
}