@@ -44,7 +44,7 @@ func TestMetrics(t *testing.T) {
44
44
45
45
reg := prometheus .NewRegistry ()
46
46
metrics := notifications .NewMetrics (reg )
47
- tmplate := notifications .TemplateWorkspaceDeleted
47
+ tmpl := notifications .TemplateWorkspaceDeleted
48
48
49
49
const (
50
50
method = database .NotificationMethodSmtp
@@ -76,7 +76,7 @@ func TestMetrics(t *testing.T) {
76
76
user := createSampleUser (t , api .Database )
77
77
78
78
// Build fingerprints for the two different series we expect.
79
- methodTemplateFP := fingerprintLabels (notifications .LabelMethod , string (method ), notifications .LabelTemplateID , tmplate .String ())
79
+ methodTemplateFP := fingerprintLabels (notifications .LabelMethod , string (method ), notifications .LabelTemplateID , tmpl .String ())
80
80
methodFP := fingerprintLabels (notifications .LabelMethod , string (method ))
81
81
82
82
expected := map [string ]func (metric * dto.Metric , series string ) bool {
@@ -90,7 +90,7 @@ func TestMetrics(t *testing.T) {
90
90
91
91
var match string
92
92
for result , val := range results {
93
- seriesFP := fingerprintLabels (notifications .LabelMethod , string (method ), notifications .LabelTemplateID , tmplate .String (), notifications .LabelResult , result )
93
+ seriesFP := fingerprintLabels (notifications .LabelMethod , string (method ), notifications .LabelTemplateID , tmpl .String (), notifications .LabelResult , result )
94
94
if ! hasMatchingFingerprint (metric , seriesFP ) {
95
95
continue
96
96
}
@@ -165,9 +165,9 @@ func TestMetrics(t *testing.T) {
165
165
}
166
166
167
167
// WHEN: 2 notifications are enqueued, 1 of which will fail until its retries are exhausted, and another which will succeed
168
- _ , err = enq .Enqueue (ctx , user .ID , tmplate , map [string ]string {"type" : "success" }, "test" ) // this will succeed
168
+ _ , err = enq .Enqueue (ctx , user .ID , tmpl , map [string ]string {"type" : "success" }, "test" ) // this will succeed
169
169
require .NoError (t , err )
170
- _ , err = enq .Enqueue (ctx , user .ID , tmplate , map [string ]string {"type" : "failure" }, "test2" ) // this will fail and retry (maxAttempts - 1) times
170
+ _ , err = enq .Enqueue (ctx , user .ID , tmpl , map [string ]string {"type" : "failure" }, "test2" ) // this will fail and retry (maxAttempts - 1) times
171
171
require .NoError (t , err )
172
172
173
173
mgr .Run (ctx )
@@ -217,7 +217,7 @@ func TestPendingUpdatesMetric(t *testing.T) {
217
217
218
218
reg := prometheus .NewRegistry ()
219
219
metrics := notifications .NewMetrics (reg )
220
- tmplate := notifications .TemplateWorkspaceDeleted
220
+ tmpl := notifications .TemplateWorkspaceDeleted
221
221
222
222
const method = database .NotificationMethodSmtp
223
223
@@ -248,9 +248,9 @@ func TestPendingUpdatesMetric(t *testing.T) {
248
248
user := createSampleUser (t , api .Database )
249
249
250
250
// WHEN: 2 notifications are enqueued, one of which will fail and one which will succeed
251
- _ , err = enq .Enqueue (ctx , user .ID , tmplate , map [string ]string {"type" : "success" }, "test" ) // this will succeed
251
+ _ , err = enq .Enqueue (ctx , user .ID , tmpl , map [string ]string {"type" : "success" }, "test" ) // this will succeed
252
252
require .NoError (t , err )
253
- _ , err = enq .Enqueue (ctx , user .ID , tmplate , map [string ]string {"type" : "failure" }, "test2" ) // this will fail and retry (maxAttempts - 1) times
253
+ _ , err = enq .Enqueue (ctx , user .ID , tmpl , map [string ]string {"type" : "failure" }, "test2" ) // this will fail and retry (maxAttempts - 1) times
254
254
require .NoError (t , err )
255
255
256
256
mgr .Run (ctx )
@@ -301,7 +301,7 @@ func TestInflightDispatchesMetric(t *testing.T) {
301
301
302
302
reg := prometheus .NewRegistry ()
303
303
metrics := notifications .NewMetrics (reg )
304
- tmplate := notifications .TemplateWorkspaceDeleted
304
+ tmpl := notifications .TemplateWorkspaceDeleted
305
305
306
306
const method = database .NotificationMethodSmtp
307
307
@@ -334,7 +334,7 @@ func TestInflightDispatchesMetric(t *testing.T) {
334
334
335
335
// WHEN: notifications are enqueued which will succeed (and be delayed during dispatch)
336
336
for i := 0 ; i < msgCount ; i ++ {
337
- _ , err = enq .Enqueue (ctx , user .ID , tmplate , map [string ]string {"type" : "success" , "i" : strconv .Itoa (i )}, "test" )
337
+ _ , err = enq .Enqueue (ctx , user .ID , tmpl , map [string ]string {"type" : "success" , "i" : strconv .Itoa (i )}, "test" )
338
338
require .NoError (t , err )
339
339
}
340
340
@@ -343,7 +343,7 @@ func TestInflightDispatchesMetric(t *testing.T) {
343
343
// THEN:
344
344
// Ensure we see the dispatches of the messages inflight.
345
345
require .Eventually (t , func () bool {
346
- return promtest .ToFloat64 (metrics .InflightDispatches .WithLabelValues (string (method ), tmplate .String ())) == msgCount
346
+ return promtest .ToFloat64 (metrics .InflightDispatches .WithLabelValues (string (method ), tmpl .String ())) == msgCount
347
347
}, testutil .WaitShort , testutil .IntervalFast )
348
348
349
349
for i := 0 ; i < msgCount ; i ++ {
@@ -380,7 +380,7 @@ func TestCustomMethodMetricCollection(t *testing.T) {
380
380
var (
381
381
reg = prometheus .NewRegistry ()
382
382
metrics = notifications .NewMetrics (reg )
383
- tmplate = notifications .TemplateWorkspaceDeleted
383
+ tmpl = notifications .TemplateWorkspaceDeleted
384
384
anotherTemplate = notifications .TemplateWorkspaceDormant
385
385
)
386
386
@@ -391,7 +391,7 @@ func TestCustomMethodMetricCollection(t *testing.T) {
391
391
392
392
// GIVEN: a template whose notification method differs from the default.
393
393
out , err := api .Database .UpdateNotificationTemplateMethodByID (ctx , database.UpdateNotificationTemplateMethodByIDParams {
394
- ID : tmplate ,
394
+ ID : tmpl ,
395
395
Method : database.NullNotificationMethod {NotificationMethod : customMethod , Valid : true },
396
396
})
397
397
require .NoError (t , err )
@@ -417,7 +417,7 @@ func TestCustomMethodMetricCollection(t *testing.T) {
417
417
418
418
user := createSampleUser (t , api .Database )
419
419
420
- _ , err = enq .Enqueue (ctx , user .ID , tmplate , map [string ]string {"type" : "success" }, "test" )
420
+ _ , err = enq .Enqueue (ctx , user .ID , tmpl , map [string ]string {"type" : "success" }, "test" )
421
421
require .NoError (t , err )
422
422
_ , err = enq .Enqueue (ctx , user .ID , anotherTemplate , map [string ]string {"type" : "success" }, "test" )
423
423
require .NoError (t , err )
@@ -438,7 +438,7 @@ func TestCustomMethodMetricCollection(t *testing.T) {
438
438
// THEN: we should have metric series for both the default and custom notification methods.
439
439
require .Eventually (t , func () bool {
440
440
return promtest .ToFloat64 (metrics .DispatchAttempts .WithLabelValues (string (defaultMethod ), anotherTemplate .String (), notifications .ResultSuccess )) > 0 &&
441
- promtest .ToFloat64 (metrics .DispatchAttempts .WithLabelValues (string (customMethod ), tmplate .String (), notifications .ResultSuccess )) > 0
441
+ promtest .ToFloat64 (metrics .DispatchAttempts .WithLabelValues (string (customMethod ), tmpl .String (), notifications .ResultSuccess )) > 0
442
442
}, testutil .WaitShort , testutil .IntervalFast )
443
443
}
444
444
0 commit comments