-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdashboard_client_fake_test.go
97 lines (92 loc) · 2.66 KB
/
dashboard_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// nolint:errcheck
package modzy
import (
"context"
"testing"
)
func TestDashboardClientFake(t *testing.T) {
expectedCtx := context.WithValue(context.TODO(), testContextKey("a"), "b")
calls := 0
fake := &DashboardClientFake{
GetAlertsFunc: func(ctx context.Context, input *GetAlertsInput) (*GetAlertsOutput, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
if input == nil {
t.Errorf("input was not passed through")
}
return nil, nil
},
GetAlertDetailsFunc: func(ctx context.Context, input *GetAlertDetailsInput) (*GetAlertDetailsOutput, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
if input == nil {
t.Errorf("input was not passed through")
}
return nil, nil
},
GetDataProcessedFunc: func(ctx context.Context, input *GetDataProcessedInput) (*GetDataProcessedOutput, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
if input == nil {
t.Errorf("input was not passed through")
}
return nil, nil
},
GetPredictionsMadeFunc: func(ctx context.Context, input *GetPredictionsMadeInput) (*GetPredictionsMadeOutput, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
if input == nil {
t.Errorf("input was not passed through")
}
return nil, nil
},
GetActiveUsersFunc: func(ctx context.Context, input *GetActiveUsersInput) (*GetActiveUsersOutput, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
if input == nil {
t.Errorf("input was not passed through")
}
return nil, nil
},
GetActiveModelsFunc: func(ctx context.Context, input *GetActiveModelsInput) (*GetActiveModelsOutput, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
if input == nil {
t.Errorf("input was not passed through")
}
return nil, nil
},
GetPrometheusMetricFunc: func(ctx context.Context, input *GetPrometheusMetricInput) (*GetPrometheusMetricOutput, error) {
calls++
if ctx != expectedCtx {
t.Errorf("not expected ctx")
}
if input == nil {
t.Errorf("input was not passed through")
}
return nil, nil
},
}
fake.GetAlerts(expectedCtx, &GetAlertsInput{})
fake.GetAlertDetails(expectedCtx, &GetAlertDetailsInput{})
fake.GetDataProcessed(expectedCtx, &GetDataProcessedInput{})
fake.GetPredictionsMade(expectedCtx, &GetPredictionsMadeInput{})
fake.GetActiveUsers(expectedCtx, &GetActiveUsersInput{})
fake.GetActiveModels(expectedCtx, &GetActiveModelsInput{})
fake.GetPrometheusMetric(expectedCtx, &GetPrometheusMetricInput{})
if calls != 7 {
t.Errorf("Did not call all of the funcs: %d", calls)
}
}