Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions codersdk/agentsdk/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,12 @@ func TestStartupLogsSender(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
defer cancel()

var want, got []agentsdk.Log
patchLogs := func(_ context.Context, req agentsdk.PatchLogs) error {
got = append(got, req.Logs...)
patchStart := make(chan struct{})
patchDone := make(chan struct{})
patchLogs := func(ctx context.Context, _ agentsdk.PatchLogs) error {
close(patchStart)
<-ctx.Done()
close(patchDone)
return nil
}

Expand All @@ -358,10 +361,14 @@ func TestStartupLogsSender(t *testing.T) {
})
require.NoError(t, err)

cancel()
go func() {
<-patchStart
cancel()
}()
err = flushAndClose(ctx)
require.Error(t, err)

require.Equal(t, want, got)
<-patchDone
// The patch request should have been canceled if it was active.
})
}