@@ -111,6 +111,9 @@ func TestUpdateStates(t *testing.T) {
111111AgentFn :func (context.Context ) (database.WorkspaceAgent ,error ) {
112112return agent ,nil
113113},
114+ WorkspaceFn :func () (database.Workspace ,error ) {
115+ return workspace ,nil
116+ },
114117Database :dbM ,
115118StatsReporter :workspacestats .NewReporter (workspacestats.ReporterOptions {
116119Database :dbM ,
@@ -136,9 +139,6 @@ func TestUpdateStates(t *testing.T) {
136139}
137140defer wut .Close ()
138141
139- // Workspace gets fetched.
140- dbM .EXPECT ().GetWorkspaceByAgentID (gomock .Any (),agent .ID ).Return (workspace ,nil )
141-
142142// We expect an activity bump because ConnectionCount > 0.
143143dbM .EXPECT ().ActivityBumpWorkspace (gomock .Any (), database.ActivityBumpWorkspaceParams {
144144WorkspaceID :workspace .ID ,
@@ -223,6 +223,9 @@ func TestUpdateStates(t *testing.T) {
223223AgentFn :func (context.Context ) (database.WorkspaceAgent ,error ) {
224224return agent ,nil
225225},
226+ WorkspaceFn :func () (database.Workspace ,error ) {
227+ return workspace ,nil
228+ },
226229Database :dbM ,
227230StatsReporter :workspacestats .NewReporter (workspacestats.ReporterOptions {
228231Database :dbM ,
@@ -239,9 +242,6 @@ func TestUpdateStates(t *testing.T) {
239242},
240243}
241244
242- // Workspace gets fetched.
243- dbM .EXPECT ().GetWorkspaceByAgentID (gomock .Any (),agent .ID ).Return (workspace ,nil )
244-
245245_ ,err := api .UpdateStats (context .Background (),req )
246246require .NoError (t ,err )
247247})
@@ -260,6 +260,9 @@ func TestUpdateStates(t *testing.T) {
260260AgentFn :func (context.Context ) (database.WorkspaceAgent ,error ) {
261261return agent ,nil
262262},
263+ WorkspaceFn :func () (database.Workspace ,error ) {
264+ return workspace ,nil
265+ },
263266Database :dbM ,
264267StatsReporter :workspacestats .NewReporter (workspacestats.ReporterOptions {
265268Database :dbM ,
@@ -337,6 +340,9 @@ func TestUpdateStates(t *testing.T) {
337340AgentFn :func (context.Context ) (database.WorkspaceAgent ,error ) {
338341return agent ,nil
339342},
343+ WorkspaceFn :func () (database.Workspace ,error ) {
344+ return workspace ,nil
345+ },
340346Database :dbM ,
341347StatsReporter :workspacestats .NewReporter (workspacestats.ReporterOptions {
342348Database :dbM ,
@@ -362,9 +368,6 @@ func TestUpdateStates(t *testing.T) {
362368}
363369defer wut .Close ()
364370
365- // Workspace gets fetched.
366- dbM .EXPECT ().GetWorkspaceByAgentID (gomock .Any (),agent .ID ).Return (workspace ,nil )
367-
368371// We expect an activity bump because ConnectionCount > 0. However, the
369372// next autostart time will be set on the bump.
370373dbM .EXPECT ().ActivityBumpWorkspace (gomock .Any (), database.ActivityBumpWorkspaceParams {
@@ -451,6 +454,9 @@ func TestUpdateStates(t *testing.T) {
451454AgentFn :func (context.Context ) (database.WorkspaceAgent ,error ) {
452455return agent ,nil
453456},
457+ WorkspaceFn :func () (database.Workspace ,error ) {
458+ return workspace ,nil
459+ },
454460Database :dbM ,
455461StatsReporter :workspacestats .NewReporter (workspacestats.ReporterOptions {
456462Database :dbM ,
@@ -478,9 +484,6 @@ func TestUpdateStates(t *testing.T) {
478484},
479485}
480486
481- // Workspace gets fetched.
482- dbM .EXPECT ().GetWorkspaceByAgentID (gomock .Any (),agent .ID ).Return (workspace ,nil )
483-
484487// We expect an activity bump because ConnectionCount > 0.
485488dbM .EXPECT ().ActivityBumpWorkspace (gomock .Any (), database.ActivityBumpWorkspaceParams {
486489WorkspaceID :workspace .ID ,