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

Commitf290472

Browse files
authored
test: wait for completion before asserting in TestAgentConnectionMonitor_BuildOutdated (#19959)
<!--If you have used AI to produce some or all of this PR, please ensure youhave read our [AI Contributionguidelines](https://coder.com/docs/about/contributing/AI_CONTRIBUTING)before submitting.-->follow on to#19836fixescoder/internal#970Same issue, different (adjacent) test.
1 parent904a308 commitf290472

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎coderd/workspaceagentsrpc_internal_test.go‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,20 @@ func TestAgentConnectionMonitor_BuildOutdated(t *testing.T) {
215215
AnyTimes().
216216
Return(database.WorkspaceBuild{ID:uuid.New()},nil)
217217

218-
gouut.monitor(ctx)
218+
done:=make(chanstruct{})
219+
gofunc() {
220+
uut.monitor(ctx)
221+
close(done)
222+
}()
219223
fConn.requireEventuallyClosed(t,websocket.StatusGoingAway,"build is outdated")
220224
fUpdater.requireEventuallySomeUpdates(t,build.WorkspaceID)
225+
_=testutil.TryReceive(ctx,t,done)// ensure monitor() exits before mDB assertions are checked.
221226
}
222227

223228
funcTestAgentConnectionMonitor_SendPings(t*testing.T) {
224229
t.Parallel()
225-
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitShort)
230+
testCtx:=testutil.Context(t,testutil.WaitShort)
231+
ctx,cancel:=context.WithCancel(testCtx)
226232
t.Cleanup(cancel)
227233
fConn:=&fakePingerCloser{}
228234
uut:=&agentConnectionMonitor{
@@ -236,7 +242,7 @@ func TestAgentConnectionMonitor_SendPings(t *testing.T) {
236242
}()
237243
fConn.requireEventuallyHasPing(t)
238244
cancel()
239-
<-done
245+
_=testutil.TryReceive(testCtx,t,done)
240246
lastPing:=uut.lastPing.Load()
241247
require.NotNil(t,lastPing)
242248
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp