MCPcopy Index your code
hub / github.com/coder/coder / TestWorkspacePrebuildsView

Function TestWorkspacePrebuildsView

coderd/database/querier_test.go:6320–6419  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6318}
6319
6320func TestWorkspacePrebuildsView(t *testing.T) {
6321 t.Parallel()
6322
6323 now := dbtime.Now()
6324 orgID := uuid.New()
6325 userID := uuid.New()
6326
6327 type workspacePrebuild struct {
6328 ID uuid.UUID
6329 Name string
6330 CreatedAt time.Time
6331 Ready bool
6332 CurrentPresetID uuid.UUID
6333 }
6334 getWorkspacePrebuilds := func(sqlDB *sql.DB) []*workspacePrebuild {
6335 rows, err := sqlDB.Query("SELECT id, name, created_at, ready, current_preset_id FROM workspace_prebuilds")
6336 require.NoError(t, err)
6337 defer rows.Close()
6338
6339 workspacePrebuilds := make([]*workspacePrebuild, 0)
6340 for rows.Next() {
6341 var wp workspacePrebuild
6342 err := rows.Scan(&wp.ID, &wp.Name, &wp.CreatedAt, &wp.Ready, &wp.CurrentPresetID)
6343 require.NoError(t, err)
6344
6345 workspacePrebuilds = append(workspacePrebuilds, &wp)
6346 }
6347
6348 return workspacePrebuilds
6349 }
6350
6351 testCases := []struct {
6352 name string
6353 readyAgents int
6354 notReadyAgents int
6355 expectReady bool
6356 }{
6357 {
6358 name: "one ready agent",
6359 readyAgents: 1,
6360 notReadyAgents: 0,
6361 expectReady: true,
6362 },
6363 {
6364 name: "one not ready agent",
6365 readyAgents: 0,
6366 notReadyAgents: 1,
6367 expectReady: false,
6368 },
6369 {
6370 name: "one ready, one not ready",
6371 readyAgents: 1,
6372 notReadyAgents: 1,
6373 expectReady: false,
6374 },
6375 {
6376 name: "both ready",
6377 readyAgents: 2,

Callers

nothing calls this directly

Calls 15

NowFunction · 0.92
UpFunction · 0.92
NewFunction · 0.92
ContextFunction · 0.92
OrganizationFunction · 0.92
UserFunction · 0.92
createPrebuiltWorkspaceFunction · 0.85
testSQLDBFunction · 0.70
createTemplateFunction · 0.70
NewMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected