TestWorkspaceFilterAllStatus tests workspace status is correctly set given a set of conditions.
(t *testing.T)
| 1804 | |
| 1805 | // TestWorkspaceFilterAllStatus tests workspace status is correctly set given a set of conditions. |
| 1806 | func TestWorkspaceFilterAllStatus(t *testing.T) { |
| 1807 | t.Parallel() |
| 1808 | |
| 1809 | // For this test, we do not care about permissions. |
| 1810 | ctx := dbauthz.AsSystemRestricted(context.Background()) |
| 1811 | db, pubsub := dbtestutil.NewDB(t) |
| 1812 | client := coderdtest.New(t, &coderdtest.Options{ |
| 1813 | Database: db, |
| 1814 | Pubsub: pubsub, |
| 1815 | }) |
| 1816 | |
| 1817 | owner := coderdtest.CreateFirstUser(t, client) |
| 1818 | |
| 1819 | file := dbgen.File(t, db, database.File{ |
| 1820 | CreatedBy: owner.UserID, |
| 1821 | }) |
| 1822 | versionJob := dbgen.ProvisionerJob(t, db, pubsub, database.ProvisionerJob{ |
| 1823 | OrganizationID: owner.OrganizationID, |
| 1824 | InitiatorID: owner.UserID, |
| 1825 | WorkerID: uuid.NullUUID{}, |
| 1826 | FileID: file.ID, |
| 1827 | Tags: database.StringMap{ |
| 1828 | "custom": "true", |
| 1829 | }, |
| 1830 | }) |
| 1831 | version := dbgen.TemplateVersion(t, db, database.TemplateVersion{ |
| 1832 | OrganizationID: owner.OrganizationID, |
| 1833 | JobID: versionJob.ID, |
| 1834 | CreatedBy: owner.UserID, |
| 1835 | }) |
| 1836 | template := dbgen.Template(t, db, database.Template{ |
| 1837 | OrganizationID: owner.OrganizationID, |
| 1838 | ActiveVersionID: version.ID, |
| 1839 | CreatedBy: owner.UserID, |
| 1840 | }) |
| 1841 | |
| 1842 | makeWorkspace := func(workspace database.WorkspaceTable, job database.ProvisionerJob, transition database.WorkspaceTransition) (database.WorkspaceTable, database.WorkspaceBuild, database.ProvisionerJob) { |
| 1843 | db := db |
| 1844 | |
| 1845 | workspace.OwnerID = owner.UserID |
| 1846 | workspace.OrganizationID = owner.OrganizationID |
| 1847 | workspace.TemplateID = template.ID |
| 1848 | workspace = dbgen.Workspace(t, db, workspace) |
| 1849 | |
| 1850 | jobID := uuid.New() |
| 1851 | job.ID = jobID |
| 1852 | job.Type = database.ProvisionerJobTypeWorkspaceBuild |
| 1853 | job.OrganizationID = owner.OrganizationID |
| 1854 | // Need to prevent acquire from getting this job. |
| 1855 | job.Tags = database.StringMap{ |
| 1856 | jobID.String(): "true", |
| 1857 | } |
| 1858 | job = dbgen.ProvisionerJob(t, db, pubsub, job) |
| 1859 | |
| 1860 | build := dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{ |
| 1861 | WorkspaceID: workspace.ID, |
| 1862 | TemplateVersionID: version.ID, |
| 1863 | BuildNumber: 1, |
nothing calls this directly
no test coverage detected