(t *testing.T)
| 379 | } |
| 380 | |
| 381 | func (tc testCase) run(t *testing.T) { |
| 382 | t.Run(tc.name, func(t *testing.T) { |
| 383 | t.Parallel() |
| 384 | t.Cleanup(func() { |
| 385 | if t.Failed() { |
| 386 | t.Logf("failed to run test: %s", tc.name) |
| 387 | t.Logf("templateVersionActive: %t", tc.templateVersionActive) |
| 388 | t.Logf("prebuildLatestTransition: %s", tc.prebuildLatestTransition) |
| 389 | t.Logf("prebuildJobStatus: %s", tc.prebuildJobStatus) |
| 390 | } |
| 391 | }) |
| 392 | clock := quartz.NewMock(t) |
| 393 | ctx := testutil.Context(t, testutil.WaitShort) |
| 394 | cfg := codersdk.PrebuildsConfig{} |
| 395 | logger := slogtest.Make( |
| 396 | t, &slogtest.Options{IgnoreErrors: true}, |
| 397 | ).Leveled(slog.LevelDebug) |
| 398 | db, pubSub := dbtestutil.NewDB(t) |
| 399 | |
| 400 | ownerID := uuid.New() |
| 401 | dbgen.User(t, db, database.User{ |
| 402 | ID: ownerID, |
| 403 | }) |
| 404 | org, template := setupTestDBTemplate(t, db, ownerID, tc.templateDeleted) |
| 405 | templateVersionID := setupTestDBTemplateVersion( |
| 406 | ctx, |
| 407 | t, |
| 408 | clock, |
| 409 | db, |
| 410 | pubSub, |
| 411 | org.ID, |
| 412 | ownerID, |
| 413 | template.ID, |
| 414 | ) |
| 415 | preset := setupTestDBPreset( |
| 416 | t, |
| 417 | db, |
| 418 | templateVersionID, |
| 419 | 1, |
| 420 | uuid.New().String(), |
| 421 | ) |
| 422 | prebuild, _ := setupTestDBPrebuild( |
| 423 | t, |
| 424 | clock, |
| 425 | db, |
| 426 | pubSub, |
| 427 | tc.prebuildLatestTransition, |
| 428 | tc.prebuildJobStatus, |
| 429 | org.ID, |
| 430 | preset, |
| 431 | template.ID, |
| 432 | templateVersionID, |
| 433 | ) |
| 434 | |
| 435 | setupTestDBPrebuildAntagonists(t, db, pubSub, org) |
| 436 | |
| 437 | if !tc.templateVersionActive { |
| 438 | // Create a new template version and mark it as active |
no test coverage detected