(t *testing.T)
| 2020 | } |
| 2021 | |
| 2022 | func TestWorkspaceBuildTimings(t *testing.T) { |
| 2023 | t.Parallel() |
| 2024 | |
| 2025 | // Setup the test environment with a template and version |
| 2026 | db, pubsub := dbtestutil.NewDB(t) |
| 2027 | ownerClient := coderdtest.New(t, &coderdtest.Options{ |
| 2028 | Database: db, |
| 2029 | Pubsub: pubsub, |
| 2030 | }) |
| 2031 | owner := coderdtest.CreateFirstUser(t, ownerClient) |
| 2032 | client, user := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID) |
| 2033 | |
| 2034 | file := dbgen.File(t, db, database.File{ |
| 2035 | CreatedBy: owner.UserID, |
| 2036 | }) |
| 2037 | versionJob := dbgen.ProvisionerJob(t, db, pubsub, database.ProvisionerJob{ |
| 2038 | OrganizationID: owner.OrganizationID, |
| 2039 | InitiatorID: user.ID, |
| 2040 | FileID: file.ID, |
| 2041 | Tags: database.StringMap{ |
| 2042 | "custom": "true", |
| 2043 | }, |
| 2044 | }) |
| 2045 | version := dbgen.TemplateVersion(t, db, database.TemplateVersion{ |
| 2046 | OrganizationID: owner.OrganizationID, |
| 2047 | JobID: versionJob.ID, |
| 2048 | CreatedBy: owner.UserID, |
| 2049 | }) |
| 2050 | template := dbgen.Template(t, db, database.Template{ |
| 2051 | OrganizationID: owner.OrganizationID, |
| 2052 | ActiveVersionID: version.ID, |
| 2053 | CreatedBy: owner.UserID, |
| 2054 | }) |
| 2055 | |
| 2056 | // Tests will run in parallel. To avoid conflicts and race conditions on the |
| 2057 | // build number, each test will have its own workspace and build. |
| 2058 | makeBuild := func(t *testing.T) database.WorkspaceBuild { |
| 2059 | ws := dbgen.Workspace(t, db, database.WorkspaceTable{ |
| 2060 | OwnerID: user.ID, |
| 2061 | OrganizationID: owner.OrganizationID, |
| 2062 | TemplateID: template.ID, |
| 2063 | }) |
| 2064 | jobID := uuid.New() |
| 2065 | job := dbgen.ProvisionerJob(t, db, pubsub, database.ProvisionerJob{ |
| 2066 | ID: jobID, |
| 2067 | OrganizationID: owner.OrganizationID, |
| 2068 | Tags: database.StringMap{jobID.String(): "true"}, |
| 2069 | }) |
| 2070 | return dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{ |
| 2071 | WorkspaceID: ws.ID, |
| 2072 | TemplateVersionID: version.ID, |
| 2073 | InitiatorID: owner.UserID, |
| 2074 | JobID: job.ID, |
| 2075 | BuildNumber: 1, |
| 2076 | }) |
| 2077 | } |
| 2078 | |
| 2079 | t.Run("NonExistentBuild", func(t *testing.T) { |
nothing calls this directly
no test coverage detected