@@ -65,7 +65,8 @@ func TestBasicNotificationRoundtrip(t *testing.T) {
65
65
interceptor := & syncInterceptor {Store : db }
66
66
cfg := defaultNotificationsConfig (method )
67
67
cfg .RetryInterval = serpent .Duration (time .Hour ) // Ensure retries don't interfere with the test
68
- mgr , err := notifications .NewManager (cfg , interceptor , createMetrics (), logger .Named ("manager" ))
68
+ accessURL := "http://localhost:8080"
69
+ mgr , err := notifications .NewManager (cfg , interceptor , accessURL , createMetrics (), logger .Named ("manager" ))
69
70
require .NoError (t , err )
70
71
mgr .WithHandlers (map [database.NotificationMethod ]notifications.Handler {method : handler })
71
72
t .Cleanup (func () {
@@ -138,8 +139,9 @@ func TestSMTPDispatch(t *testing.T) {
138
139
Smarthost : serpent.HostPort {Host : "localhost" , Port : fmt .Sprintf ("%d" , mockSMTPSrv .PortNumber ())},
139
140
Hello : "localhost" ,
140
141
}
141
- handler := newDispatchInterceptor (dispatch .NewSMTPHandler (cfg .SMTP , logger .Named ("smtp" )))
142
- mgr , err := notifications .NewManager (cfg , db , createMetrics (), logger .Named ("manager" ))
142
+ accessURL := "http://localhost:8080"
143
+ handler := newDispatchInterceptor (dispatch .NewSMTPHandler (cfg .SMTP , accessURL , logger .Named ("smtp" )))
144
+ mgr , err := notifications .NewManager (cfg , db , accessURL , createMetrics (), logger .Named ("manager" ))
143
145
require .NoError (t , err )
144
146
mgr .WithHandlers (map [database.NotificationMethod ]notifications.Handler {method : handler })
145
147
t .Cleanup (func () {
@@ -200,7 +202,8 @@ func TestWebhookDispatch(t *testing.T) {
200
202
cfg .Webhook = codersdk.NotificationsWebhookConfig {
201
203
Endpoint : * serpent .URLOf (endpoint ),
202
204
}
203
- mgr , err := notifications .NewManager (cfg , db , createMetrics (), logger .Named ("manager" ))
205
+ accessURL := "http://localhost:8080"
206
+ mgr , err := notifications .NewManager (cfg , db , accessURL , createMetrics (), logger .Named ("manager" ))
204
207
require .NoError (t , err )
205
208
t .Cleanup (func () {
206
209
assert .NoError (t , mgr .Stop (ctx ))
@@ -298,7 +301,8 @@ func TestBackpressure(t *testing.T) {
298
301
storeInterceptor := & syncInterceptor {Store : db }
299
302
300
303
// GIVEN: a notification manager whose updates will be intercepted
301
- mgr , err := notifications .NewManager (cfg , storeInterceptor , createMetrics (), logger .Named ("manager" ))
304
+ accessURL := "http://localhost:8080"
305
+ mgr , err := notifications .NewManager (cfg , storeInterceptor , accessURL , createMetrics (), logger .Named ("manager" ))
302
306
require .NoError (t , err )
303
307
mgr .WithHandlers (map [database.NotificationMethod ]notifications.Handler {method : handler })
304
308
enq , err := notifications .NewStoreEnqueuer (cfg , db , defaultHelpers (), logger .Named ("enqueuer" ))
@@ -393,7 +397,8 @@ func TestRetries(t *testing.T) {
393
397
// Intercept calls to submit the buffered updates to the store.
394
398
storeInterceptor := & syncInterceptor {Store : db }
395
399
396
- mgr , err := notifications .NewManager (cfg , storeInterceptor , createMetrics (), logger .Named ("manager" ))
400
+ accessURL := "http://localhost:8080"
401
+ mgr , err := notifications .NewManager (cfg , storeInterceptor , accessURL , createMetrics (), logger .Named ("manager" ))
397
402
require .NoError (t , err )
398
403
t .Cleanup (func () {
399
404
assert .NoError (t , mgr .Stop (ctx ))
@@ -454,7 +459,8 @@ func TestExpiredLeaseIsRequeued(t *testing.T) {
454
459
mgrCtx , cancelManagerCtx := context .WithCancel (context .Background ())
455
460
t .Cleanup (cancelManagerCtx )
456
461
457
- mgr , err := notifications .NewManager (cfg , noopInterceptor , createMetrics (), logger .Named ("manager" ))
462
+ accessURL := "http://localhost:8080"
463
+ mgr , err := notifications .NewManager (cfg , noopInterceptor , accessURL , createMetrics (), logger .Named ("manager" ))
458
464
require .NoError (t , err )
459
465
enq , err := notifications .NewStoreEnqueuer (cfg , db , defaultHelpers (), logger .Named ("enqueuer" ))
460
466
require .NoError (t , err )
@@ -501,7 +507,7 @@ func TestExpiredLeaseIsRequeued(t *testing.T) {
501
507
// Intercept calls to submit the buffered updates to the store.
502
508
storeInterceptor := & syncInterceptor {Store : db }
503
509
handler := newDispatchInterceptor (& fakeHandler {})
504
- mgr , err = notifications .NewManager (cfg , storeInterceptor , createMetrics (), logger .Named ("manager" ))
510
+ mgr , err = notifications .NewManager (cfg , storeInterceptor , accessURL , createMetrics (), logger .Named ("manager" ))
505
511
require .NoError (t , err )
506
512
mgr .WithHandlers (map [database.NotificationMethod ]notifications.Handler {method : handler })
507
513
@@ -542,7 +548,8 @@ func TestInvalidConfig(t *testing.T) {
542
548
cfg .DispatchTimeout = serpent .Duration (leasePeriod )
543
549
544
550
// WHEN: the manager is created with invalid config
545
- _ , err := notifications .NewManager (cfg , db , createMetrics (), logger .Named ("manager" ))
551
+ accessURL := "http://localhost:8080"
552
+ _ , err := notifications .NewManager (cfg , db , accessURL , createMetrics (), logger .Named ("manager" ))
546
553
547
554
// THEN: the manager will fail to be created, citing invalid config as error
548
555
require .ErrorIs (t , err , notifications .ErrInvalidDispatchTimeout )
@@ -560,7 +567,8 @@ func TestNotifierPaused(t *testing.T) {
560
567
user := createSampleUser (t , db )
561
568
562
569
cfg := defaultNotificationsConfig (method )
563
- mgr , err := notifications .NewManager (cfg , db , createMetrics (), logger .Named ("manager" ))
570
+ accessURL := "http://localhost:8080"
571
+ mgr , err := notifications .NewManager (cfg , db , accessURL , createMetrics (), logger .Named ("manager" ))
564
572
require .NoError (t , err )
565
573
mgr .WithHandlers (map [database.NotificationMethod ]notifications.Handler {method : handler })
566
574
t .Cleanup (func () {
@@ -830,8 +838,9 @@ func TestDisabledAfterEnqueue(t *testing.T) {
830
838
831
839
method := database .NotificationMethodSmtp
832
840
cfg := defaultNotificationsConfig (method )
841
+ accessURL := "http://localhost:8080"
833
842
834
- mgr , err := notifications .NewManager (cfg , db , createMetrics (), logger .Named ("manager" ))
843
+ mgr , err := notifications .NewManager (cfg , db , accessURL , createMetrics (), logger .Named ("manager" ))
835
844
require .NoError (t , err )
836
845
t .Cleanup (func () {
837
846
assert .NoError (t , mgr .Stop (ctx ))
@@ -937,7 +946,8 @@ func TestCustomNotificationMethod(t *testing.T) {
937
946
Endpoint : * serpent .URLOf (endpoint ),
938
947
}
939
948
940
- mgr , err := notifications .NewManager (cfg , db , createMetrics (), logger .Named ("manager" ))
949
+ accessURL := "http://localhost:8080"
950
+ mgr , err := notifications .NewManager (cfg , db , accessURL , createMetrics (), logger .Named ("manager" ))
941
951
require .NoError (t , err )
942
952
t .Cleanup (func () {
943
953
_ = mgr .Stop (ctx )
0 commit comments