Skip to content

Commit 61f2b7e

Browse files
committed
fix tests
1 parent 5171f71 commit 61f2b7e

File tree

1 file changed

+2
-34
lines changed

1 file changed

+2
-34
lines changed

coderd/agentapi/stats_test.go

+2-34
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,6 @@ func TestUpdateStates(t *testing.T) {
230230
TemplateName: template.Name,
231231
}, nil)
232232

233-
// Workspace last used at gets bumped.
234-
dbM.EXPECT().UpdateWorkspaceLastUsedAt(gomock.Any(), database.UpdateWorkspaceLastUsedAtParams{
235-
ID: workspace.ID,
236-
LastUsedAt: now,
237-
}).Return(nil)
238-
239233
_, err := api.UpdateStats(context.Background(), req)
240234
require.NoError(t, err)
241235
})
@@ -319,6 +313,7 @@ func TestUpdateStates(t *testing.T) {
319313
"dean": 2,
320314
},
321315
ConnectionCount: 3,
316+
SessionCountSsh: 3,
322317
},
323318
}
324319
)
@@ -355,7 +350,7 @@ func TestUpdateStates(t *testing.T) {
355350
TemplateName: template.Name,
356351
}, nil)
357352

358-
// We expect an activity bump because ConnectionCount > 0. However, the
353+
// We expect an activity bump because SessionCountSsh > 0. However, the
359354
// next autostart time will be set on the bump.
360355
dbM.EXPECT().ActivityBumpWorkspace(gomock.Any(), database.ActivityBumpWorkspaceParams{
361356
WorkspaceID: workspace.ID,
@@ -466,29 +461,9 @@ func TestUpdateStates(t *testing.T) {
466461
TemplateName: template.Name,
467462
}, nil)
468463

469-
// We expect an activity bump because ConnectionCount > 0.
470-
dbM.EXPECT().ActivityBumpWorkspace(gomock.Any(), database.ActivityBumpWorkspaceParams{
471-
WorkspaceID: workspace.ID,
472-
NextAutostart: time.Time{}.UTC(),
473-
}).Return(nil)
474-
475-
// Workspace last used at gets bumped.
476-
dbM.EXPECT().UpdateWorkspaceLastUsedAt(gomock.Any(), database.UpdateWorkspaceLastUsedAtParams{
477-
ID: workspace.ID,
478-
LastUsedAt: now,
479-
}).Return(nil)
480-
481464
// User gets fetched to hit the UpdateAgentMetricsFn.
482465
dbM.EXPECT().GetUserByID(gomock.Any(), user.ID).Return(user, nil)
483466

484-
// Ensure that pubsub notifications are sent.
485-
notifyDescription := make(chan []byte)
486-
ps.Subscribe(codersdk.WorkspaceNotifyChannel(workspace.ID), func(_ context.Context, description []byte) {
487-
go func() {
488-
notifyDescription <- description
489-
}()
490-
})
491-
492467
resp, err := api.UpdateStats(context.Background(), req)
493468
require.NoError(t, err)
494469
require.Equal(t, &agentproto.UpdateStatsResponse{
@@ -502,13 +477,6 @@ func TestUpdateStates(t *testing.T) {
502477
require.EqualValues(t, 0, batcher.LastStats.SessionCountJetbrains)
503478
require.EqualValues(t, 0, batcher.LastStats.SessionCountVscode)
504479
require.EqualValues(t, 0, batcher.LastStats.SessionCountReconnectingPty)
505-
ctx := testutil.Context(t, testutil.WaitShort)
506-
select {
507-
case <-ctx.Done():
508-
t.Error("timed out while waiting for pubsub notification")
509-
case description := <-notifyDescription:
510-
require.Equal(t, description, []byte{})
511-
}
512480
require.True(t, updateAgentMetricsFnCalled)
513481
})
514482
}

0 commit comments

Comments
 (0)