nolint:revive // It's a control flag, but this is a test.
(t *testing.T, db database.Store, workspaceID uuid.UUID, eligible bool)
| 3288 | |
| 3289 | // nolint:revive // It's a control flag, but this is a test. |
| 3290 | func setupTestDBWorkspaceAgent(t *testing.T, db database.Store, workspaceID uuid.UUID, eligible bool) database.WorkspaceAgent { |
| 3291 | build, err := db.GetLatestWorkspaceBuildByWorkspaceID(t.Context(), workspaceID) |
| 3292 | require.NoError(t, err) |
| 3293 | |
| 3294 | res := dbgen.WorkspaceResource(t, db, database.WorkspaceResource{JobID: build.JobID}) |
| 3295 | agent := dbgen.WorkspaceAgent(t, db, database.WorkspaceAgent{ |
| 3296 | ResourceID: res.ID, |
| 3297 | }) |
| 3298 | |
| 3299 | // A prebuilt workspace is considered eligible when its agent is in a "ready" lifecycle state. |
| 3300 | // i.e. connected to the control plane and all startup scripts have run. |
| 3301 | if eligible { |
| 3302 | require.NoError(t, db.UpdateWorkspaceAgentLifecycleStateByID(t.Context(), database.UpdateWorkspaceAgentLifecycleStateByIDParams{ |
| 3303 | ID: agent.ID, |
| 3304 | LifecycleState: database.WorkspaceAgentLifecycleStateReady, |
| 3305 | StartedAt: sql.NullTime{Time: dbtime.Now().Add(-time.Minute), Valid: true}, |
| 3306 | ReadyAt: sql.NullTime{Time: dbtime.Now(), Valid: true}, |
| 3307 | })) |
| 3308 | } |
| 3309 | |
| 3310 | return agent |
| 3311 | } |
| 3312 | |
| 3313 | // setupTestDBAntagonists creates test antagonists that should not influence running prebuild workspace tests. |
| 3314 | // 1. A stopped prebuilt workspace (STOP then START transitions, owned by |
no test coverage detected