@@ -108,6 +108,7 @@ func TestUpdateStates(t *testing.T) {
108
108
Database : dbM ,
109
109
Pubsub : ps ,
110
110
StatsBatcher : batcher ,
111
+ UsageTracker : workspacestats .NewTracker (dbM ),
111
112
TemplateScheduleStore : templateScheduleStorePtr (templateScheduleStore ),
112
113
UpdateAgentMetricsFn : func (ctx context.Context , labels prometheusmetrics.AgentMetricLabels , metrics []* agentproto.Stats_Metric ) {
113
114
updateAgentMetricsFnCalled = true
@@ -132,21 +133,15 @@ func TestUpdateStates(t *testing.T) {
132
133
TemplateName : template .Name ,
133
134
}, nil )
134
135
136
+ // User gets fetched to hit the UpdateAgentMetricsFn.
137
+ dbM .EXPECT ().GetUserByID (gomock .Any (), user .ID ).Return (user , nil )
138
+
135
139
// We expect an activity bump because ConnectionCount > 0.
136
140
dbM .EXPECT ().ActivityBumpWorkspace (gomock .Any (), database.ActivityBumpWorkspaceParams {
137
141
WorkspaceID : workspace .ID ,
138
142
NextAutostart : time.Time {}.UTC (),
139
143
}).Return (nil )
140
144
141
- // Workspace last used at gets bumped.
142
- dbM .EXPECT ().UpdateWorkspaceLastUsedAt (gomock .Any (), database.UpdateWorkspaceLastUsedAtParams {
143
- ID : workspace .ID ,
144
- LastUsedAt : now ,
145
- }).Return (nil )
146
-
147
- // User gets fetched to hit the UpdateAgentMetricsFn.
148
- dbM .EXPECT ().GetUserByID (gomock .Any (), user .ID ).Return (user , nil )
149
-
150
145
// Ensure that pubsub notifications are sent.
151
146
notifyDescription := make (chan []byte )
152
147
ps .Subscribe (codersdk .WorkspaceNotifyChannel (workspace .ID ), func (_ context.Context , description []byte ) {
@@ -230,12 +225,6 @@ func TestUpdateStates(t *testing.T) {
230
225
TemplateName : template .Name ,
231
226
}, nil )
232
227
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
-
239
228
_ , err := api .UpdateStats (context .Background (), req )
240
229
require .NoError (t , err )
241
230
})
0 commit comments