@@ -39,7 +39,9 @@ func TestEventLoop(t *testing.T) {
39
39
description : "Test low sev alert sends to slack" ,
40
40
test : func (t * testing.T ) {
41
41
cm := alert .NewRoutingDirectory (cfg .AlertConfig )
42
- am := alert .NewManager (ctx , cfg .AlertConfig , cm )
42
+ sns := mocks .NewMockSNSClient (c )
43
+
44
+ am := alert .NewManager (ctx , cfg .AlertConfig , cm , sns )
43
45
44
46
go func () {
45
47
_ = am .EventLoop ()
@@ -76,6 +78,12 @@ func TestEventLoop(t *testing.T) {
76
78
}, nil ).Times (1 )
77
79
}
78
80
81
+ sns .EXPECT ().PostEvent (gomock .Any (), gomock .Any ()).Return (
82
+ & client.AlertAPIResponse {
83
+ Message : "test" ,
84
+ Status : core .SuccessStatus ,
85
+ }, nil ).AnyTimes ()
86
+
79
87
ingress <- alert
80
88
time .Sleep (1 * time .Second )
81
89
id := core .NewUUID ()
@@ -93,7 +101,8 @@ func TestEventLoop(t *testing.T) {
93
101
description : "Test medium sev alert sends to just PagerDuty" ,
94
102
test : func (t * testing.T ) {
95
103
cm := alert .NewRoutingDirectory (cfg .AlertConfig )
96
- am := alert .NewManager (ctx , cfg .AlertConfig , cm )
104
+ sns := mocks .NewMockSNSClient (c )
105
+ am := alert .NewManager (ctx , cfg .AlertConfig , cm , sns )
97
106
98
107
go func () {
99
108
_ = am .EventLoop ()
@@ -130,6 +139,12 @@ func TestEventLoop(t *testing.T) {
130
139
}, nil ).Times (1 )
131
140
}
132
141
142
+ sns .EXPECT ().PostEvent (gomock .Any (), gomock .Any ()).Return (
143
+ & client.AlertAPIResponse {
144
+ Message : "test" ,
145
+ Status : core .SuccessStatus ,
146
+ }, nil ).AnyTimes ()
147
+
133
148
ingress <- alert
134
149
time .Sleep (1 * time .Second )
135
150
id := core.UUID {}
@@ -147,7 +162,8 @@ func TestEventLoop(t *testing.T) {
147
162
description : "Test high sev alert sends to both slack and PagerDuty" ,
148
163
test : func (t * testing.T ) {
149
164
cm := alert .NewRoutingDirectory (cfg .AlertConfig )
150
- am := alert .NewManager (ctx , cfg .AlertConfig , cm )
165
+ sns := mocks .NewMockSNSClient (c )
166
+ am := alert .NewManager (ctx , cfg .AlertConfig , cm , sns )
151
167
152
168
go func () {
153
169
_ = am .EventLoop ()
@@ -181,7 +197,7 @@ func TestEventLoop(t *testing.T) {
181
197
& client.AlertAPIResponse {
182
198
Message : "test" ,
183
199
Status : core .SuccessStatus ,
184
- }, nil ). Times ( 1 )
200
+ }, nil )
185
201
}
186
202
187
203
for _ , cli := range cm .GetSlackClients (core .HIGH ) {
@@ -191,8 +207,15 @@ func TestEventLoop(t *testing.T) {
191
207
& client.AlertAPIResponse {
192
208
Message : "test" ,
193
209
Status : core .SuccessStatus ,
194
- }, nil ). Times ( 1 )
210
+ }, nil )
195
211
}
212
+
213
+ sns .EXPECT ().PostEvent (gomock .Any (), gomock .Any ()).Return (
214
+ & client.AlertAPIResponse {
215
+ Message : "test" ,
216
+ Status : core .SuccessStatus ,
217
+ }, nil ).AnyTimes ()
218
+
196
219
ingress <- alert
197
220
time .Sleep (1 * time .Second )
198
221
id := core.UUID {}
0 commit comments