(t *testing.T)
| 615 | } |
| 616 | |
| 617 | func TestNotifications(t *testing.T) { |
| 618 | t.Parallel() |
| 619 | |
| 620 | t.Run("Dormancy", func(t *testing.T) { |
| 621 | t.Parallel() |
| 622 | |
| 623 | var ( |
| 624 | db, _ = dbtestutil.NewDB(t) |
| 625 | ctx = testutil.Context(t, testutil.WaitLong) |
| 626 | user = dbgen.User(t, db, database.User{}) |
| 627 | file = dbgen.File(t, db, database.File{ |
| 628 | CreatedBy: user.ID, |
| 629 | }) |
| 630 | templateJob = dbgen.ProvisionerJob(t, db, nil, database.ProvisionerJob{ |
| 631 | FileID: file.ID, |
| 632 | InitiatorID: user.ID, |
| 633 | Tags: database.StringMap{ |
| 634 | "foo": "bar", |
| 635 | }, |
| 636 | }) |
| 637 | timeTilDormant = time.Minute * 2 |
| 638 | templateVersion = dbgen.TemplateVersion(t, db, database.TemplateVersion{ |
| 639 | CreatedBy: user.ID, |
| 640 | JobID: templateJob.ID, |
| 641 | OrganizationID: templateJob.OrganizationID, |
| 642 | }) |
| 643 | template = dbgen.Template(t, db, database.Template{ |
| 644 | ActiveVersionID: templateVersion.ID, |
| 645 | CreatedBy: user.ID, |
| 646 | OrganizationID: templateJob.OrganizationID, |
| 647 | TimeTilDormant: int64(timeTilDormant), |
| 648 | TimeTilDormantAutoDelete: int64(timeTilDormant), |
| 649 | }) |
| 650 | ) |
| 651 | |
| 652 | // Add two dormant workspaces and one active workspace. |
| 653 | dormantWorkspaces := []database.WorkspaceTable{ |
| 654 | dbgen.Workspace(t, db, database.WorkspaceTable{ |
| 655 | OwnerID: user.ID, |
| 656 | TemplateID: template.ID, |
| 657 | OrganizationID: templateJob.OrganizationID, |
| 658 | LastUsedAt: time.Now().Add(-time.Hour), |
| 659 | }), |
| 660 | dbgen.Workspace(t, db, database.WorkspaceTable{ |
| 661 | OwnerID: user.ID, |
| 662 | TemplateID: template.ID, |
| 663 | OrganizationID: templateJob.OrganizationID, |
| 664 | LastUsedAt: time.Now().Add(-time.Hour), |
| 665 | }), |
| 666 | } |
| 667 | dbgen.Workspace(t, db, database.WorkspaceTable{ |
| 668 | OwnerID: user.ID, |
| 669 | TemplateID: template.ID, |
| 670 | OrganizationID: templateJob.OrganizationID, |
| 671 | LastUsedAt: time.Now(), |
| 672 | }) |
| 673 | for _, ws := range dormantWorkspaces { |
| 674 | db.UpdateWorkspaceDormantDeletingAt(ctx, database.UpdateWorkspaceDormantDeletingAtParams{ |
nothing calls this directly
no test coverage detected