Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit33b0eda

Browse files
committed
TestBufferedUpdates does not need a real db, altering test details slightly
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent2f78cfd commit33b0eda

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

‎coderd/notifications/manager_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88
"time"
99

10+
"github.com/coder/coder/v2/coderd/database/pubsub"
1011
"github.com/google/uuid"
1112
"github.com/stretchr/testify/require"
1213
"golang.org/x/xerrors"
@@ -49,7 +50,9 @@ func TestBufferedUpdates(t *testing.T) {
4950
t.Parallel()
5051

5152
// setup
52-
ctx,logger,db,ps:=setup(t)
53+
ctx:=context.Background()
54+
logger:=slogtest.Make(t,&slogtest.Options{IgnoreErrors:true,IgnoredErrorIs: []error{}}).Leveled(slog.LevelDebug)
55+
db:=dbmem.New()
5356
interceptor:=&bulkUpdateInterceptor{Store:db}
5457

5558
santa:=&santaHandler{}
@@ -59,13 +62,16 @@ func TestBufferedUpdates(t *testing.T) {
5962
require.NoError(t,err)
6063
mgr.WithHandlers(handlers)
6164

62-
client:=coderdtest.New(t,&coderdtest.Options{Database:db,Pubsub:ps})
65+
client:=coderdtest.New(t,&coderdtest.Options{Database:db,Pubsub:pubsub.NewInMemory()})
6366
user:=coderdtest.CreateFirstUser(t,client)
6467

6568
// given
6669
if_,err:=mgr.Enqueue(ctx,user.UserID,notifications.TemplateWorkspaceDeleted, types.Labels{"nice":"true"},"");true {
6770
require.NoError(t,err)
6871
}
72+
if_,err:=mgr.Enqueue(ctx,user.UserID,notifications.TemplateWorkspaceDeleted, types.Labels{"nice":"true"},"");true {
73+
require.NoError(t,err)
74+
}
6975
if_,err:=mgr.Enqueue(ctx,user.UserID,notifications.TemplateWorkspaceDeleted, types.Labels{"nice":"false"},"");true {
7076
require.NoError(t,err)
7177
}
@@ -76,13 +82,13 @@ func TestBufferedUpdates(t *testing.T) {
7682
// then
7783

7884
// Wait for messages to be dispatched.
79-
require.Eventually(t,func()bool {returnsanta.naughty.Load()==1&&santa.nice.Load()==1 },testutil.WaitMedium,testutil.IntervalFast)
85+
require.Eventually(t,func()bool {returnsanta.naughty.Load()==1&&santa.nice.Load()==2 },testutil.WaitMedium,testutil.IntervalFast)
8086

8187
// Stop the manager which forces an update of buffered updates.
8288
require.NoError(t,mgr.Stop(ctx))
8389

8490
// Wait until both success & failure updates have been sent to the store.
85-
require.Eventually(t,func()bool {returninterceptor.failed.Load()==1&&interceptor.sent.Load()==1 },testutil.WaitMedium,testutil.IntervalFast)
91+
require.Eventually(t,func()bool {returninterceptor.failed.Load()==1&&interceptor.sent.Load()==2 },testutil.WaitMedium,testutil.IntervalFast)
8692
}
8793

8894
funcTestBuildPayload(t*testing.T) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp