@@ -17,6 +17,8 @@ import (
17
17
"github.com/stretchr/testify/require"
18
18
"go.uber.org/goleak"
19
19
20
+ "github.com/coder/serpent"
21
+
20
22
"github.com/coder/coder/v2/coderd/coderdtest"
21
23
"github.com/coder/coder/v2/coderd/database"
22
24
"github.com/coder/coder/v2/coderd/database/dbtestutil"
@@ -25,7 +27,6 @@ import (
25
27
"github.com/coder/coder/v2/coderd/notifications/types"
26
28
"github.com/coder/coder/v2/codersdk"
27
29
"github.com/coder/coder/v2/testutil"
28
- "github.com/coder/serpent"
29
30
)
30
31
31
32
func TestMain (m * testing.M ) {
@@ -62,9 +63,9 @@ func TestBasicNotificationRoundtrip(t *testing.T) {
62
63
user := coderdtest .CreateFirstUser (t , client )
63
64
64
65
// when
65
- sid , err := enq .Enqueue (ctx , user .UserID , notifications .TemplateWorkspaceDeleted , types. Labels {"type" : "success" }, "test" )
66
+ sid , err := enq .Enqueue (ctx , user .UserID , notifications .TemplateWorkspaceDeleted , map [ string ] string {"type" : "success" }, "test" )
66
67
require .NoError (t , err )
67
- fid , err := enq .Enqueue (ctx , user .UserID , notifications .TemplateWorkspaceDeleted , types. Labels {"type" : "failure" }, "test" )
68
+ fid , err := enq .Enqueue (ctx , user .UserID , notifications .TemplateWorkspaceDeleted , map [ string ] string {"type" : "failure" }, "test" )
68
69
require .NoError (t , err )
69
70
70
71
mgr .Run (ctx , 1 )
@@ -120,7 +121,7 @@ func TestSMTPDispatch(t *testing.T) {
120
121
})
121
122
122
123
// when
123
- msgID , err := enq .Enqueue (ctx , user .ID , notifications .TemplateWorkspaceDeleted , types. Labels {}, "test" )
124
+ msgID , err := enq .Enqueue (ctx , user .ID , notifications .TemplateWorkspaceDeleted , map [ string ] string {}, "test" )
124
125
require .NoError (t , err )
125
126
126
127
mgr .Run (ctx , 1 )
@@ -150,7 +151,7 @@ func TestWebhookDispatch(t *testing.T) {
150
151
151
152
var (
152
153
msgID * uuid.UUID
153
- input types. Labels
154
+ input map [ string ] string
154
155
)
155
156
156
157
sent := make (chan bool , 1 )
@@ -201,7 +202,7 @@ func TestWebhookDispatch(t *testing.T) {
201
202
})
202
203
203
204
// when
204
- input = types. Labels {
205
+ input = map [ string ] string {
205
206
"a" : "b" ,
206
207
"c" : "d" ,
207
208
}
@@ -284,7 +285,7 @@ func TestBackpressure(t *testing.T) {
284
285
// when
285
286
const totalMessages = 30
286
287
for i := 0 ; i < totalMessages ; i ++ {
287
- _ , err = enq .Enqueue (ctx , user .ID , notifications .TemplateWorkspaceDeleted , types. Labels {"i" : fmt .Sprintf ("%d" , i )}, "test" )
288
+ _ , err = enq .Enqueue (ctx , user .ID , notifications .TemplateWorkspaceDeleted , map [ string ] string {"i" : fmt .Sprintf ("%d" , i )}, "test" )
288
289
require .NoError (t , err )
289
290
}
290
291
@@ -389,7 +390,7 @@ func TestRetries(t *testing.T) {
389
390
390
391
// when
391
392
for i := 0 ; i < 1 ; i ++ {
392
- _ , err = enq .Enqueue (ctx , user .ID , notifications .TemplateWorkspaceDeleted , types. Labels {"i" : fmt .Sprintf ("%d" , i )}, "test" )
393
+ _ , err = enq .Enqueue (ctx , user .ID , notifications .TemplateWorkspaceDeleted , map [ string ] string {"i" : fmt .Sprintf ("%d" , i )}, "test" )
393
394
require .NoError (t , err )
394
395
}
395
396
@@ -415,7 +416,7 @@ func (*fakeHandler) NotificationMethod() database.NotificationMethod {
415
416
416
417
func (f * fakeHandler ) Dispatcher (payload types.MessagePayload , _ , _ string ) (dispatch.DeliveryFunc , error ) {
417
418
return func (ctx context.Context , msgID uuid.UUID ) (retryable bool , err error ) {
418
- if payload .Labels . Get ( "type" ) == "success" {
419
+ if payload .Labels [ "type" ] == "success" {
419
420
f .succeeded = msgID .String ()
420
421
} else {
421
422
f .failed = msgID .String ()
0 commit comments