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

Function TestDetectorPushesLogs

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

Source from the content-addressed store, hash-verified

602}
603
604func TestDetectorPushesLogs(t *testing.T) {
605 t.Parallel()
606
607 cases := []struct {
608 name string
609 preLogCount int
610 preLogStage string
611 expectStage string
612 }{
613 {
614 name: "WithExistingLogs",
615 preLogCount: 10,
616 preLogStage: "Stage Name",
617 expectStage: "Stage Name",
618 },
619 {
620 name: "WithExistingLogsNoStage",
621 preLogCount: 10,
622 preLogStage: "",
623 expectStage: "Unknown",
624 },
625 {
626 name: "WithoutExistingLogs",
627 preLogCount: 0,
628 expectStage: "Unknown",
629 },
630 }
631
632 for _, c := range cases {
633 t.Run(c.name, func(t *testing.T) {
634 t.Parallel()
635
636 ctx := testutil.Context(t, testutil.WaitLong)
637 env := newDetectorTestEnv(ctx, t)
638 defer env.close()
639
640 var (
641 now = time.Now()
642 tenMinAgo = now.Add(-time.Minute * 10)
643 sixMinAgo = now.Add(-time.Minute * 6)
644 org = dbgen.Organization(t, env.DB, database.Organization{})
645 user = dbgen.User(t, env.DB, database.User{})
646 file = dbgen.File(t, env.DB, database.File{})
647
648 // Template import job.
649 templateImportJob = dbgen.ProvisionerJob(t, env.DB, env.Pubsub, database.ProvisionerJob{
650 CreatedAt: tenMinAgo,
651 UpdatedAt: sixMinAgo,
652 StartedAt: sql.NullTime{
653 Time: tenMinAgo,
654 Valid: true,
655 },
656 OrganizationID: org.ID,
657 InitiatorID: user.ID,
658 Provisioner: database.ProvisionerTypeEcho,
659 StorageMethod: database.ProvisionerStorageMethodFile,
660 FileID: file.ID,
661 Type: database.ProvisionerJobTypeTemplateVersionImport,

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
JobLogMessagesFunction · 0.92
newDetectorTestEnvFunction · 0.85
LogMethod · 0.80
DurationMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected