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

Function TestDetectorPendingOtherJobTypes

coderd/jobreaper/detector_test.go:475–549  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

473}
474
475func TestDetectorPendingOtherJobTypes(t *testing.T) {
476 t.Parallel()
477
478 ctx := testutil.Context(t, testutil.WaitLong)
479 env := newDetectorTestEnv(ctx, t)
480 defer env.close()
481
482 var (
483 now = time.Now()
484 thirtyFiveMinAgo = now.Add(-time.Minute * 35)
485 org = dbgen.Organization(t, env.DB, database.Organization{})
486 user = dbgen.User(t, env.DB, database.User{})
487 file = dbgen.File(t, env.DB, database.File{})
488
489 // Template import job.
490 templateImportJob = dbgen.ProvisionerJob(t, env.DB, env.Pubsub, database.ProvisionerJob{
491 CreatedAt: thirtyFiveMinAgo,
492 UpdatedAt: thirtyFiveMinAgo,
493 StartedAt: sql.NullTime{
494 Time: time.Time{},
495 Valid: false,
496 },
497 OrganizationID: org.ID,
498 InitiatorID: user.ID,
499 Provisioner: database.ProvisionerTypeEcho,
500 StorageMethod: database.ProvisionerStorageMethodFile,
501 FileID: file.ID,
502 Type: database.ProvisionerJobTypeTemplateVersionImport,
503 Input: []byte("{}"),
504 })
505 _ = dbgen.TemplateVersion(t, env.DB, database.TemplateVersion{
506 OrganizationID: org.ID,
507 JobID: templateImportJob.ID,
508 CreatedBy: user.ID,
509 })
510 )
511
512 // Template dry-run job.
513 dryRunVersion := dbgen.TemplateVersion(t, env.DB, database.TemplateVersion{
514 OrganizationID: org.ID,
515 CreatedBy: user.ID,
516 })
517 input, err := json.Marshal(provisionerdserver.TemplateVersionDryRunJob{
518 TemplateVersionID: dryRunVersion.ID,
519 })
520 require.NoError(t, err)
521 templateDryRunJob := dbgen.ProvisionerJob(t, env.DB, env.Pubsub, database.ProvisionerJob{
522 CreatedAt: thirtyFiveMinAgo,
523 UpdatedAt: thirtyFiveMinAgo,
524 StartedAt: sql.NullTime{
525 Time: time.Time{},
526 Valid: false,
527 },
528 OrganizationID: org.ID,
529 InitiatorID: user.ID,
530 Provisioner: database.ProvisionerTypeEcho,
531 StorageMethod: database.ProvisionerStorageMethodFile,
532 FileID: file.ID,

Callers

nothing calls this directly

Calls 15

ContextFunction · 0.92
OrganizationFunction · 0.92
UserFunction · 0.92
FileFunction · 0.92
ProvisionerJobFunction · 0.92
TemplateVersionFunction · 0.92
newDetectorTestEnvFunction · 0.85
requireTerminatedJobFunction · 0.85
LogMethod · 0.80
closeMethod · 0.65
AddMethod · 0.65
MarshalMethod · 0.45

Tested by

no test coverage detected