Skip to content

feat: add dbfake for workspace builds and resources #10426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 2, 2023
Merged
Prev Previous commit
Next Next commit
Actually fix tests
  • Loading branch information
kylecarbs committed Nov 2, 2023
commit 38495775505075d5e0150bdb3dd31b5209b3f1e6
14 changes: 13 additions & 1 deletion coderd/database/dbfake/dbfake.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ func WorkspaceBuild(t testing.TB, db database.Store, ws database.Workspace, seed
})
require.NoError(t, err)
//nolint:gocritic // This is only used by tests.
job, err := db.InsertProvisionerJob(dbauthz.AsSystemRestricted(context.Background()), database.InsertProvisionerJobParams{
ctx := dbauthz.AsSystemRestricted(context.Background())
job, err := db.InsertProvisionerJob(ctx, database.InsertProvisionerJobParams{
ID: jobID,
CreatedAt: dbtime.Now(),
UpdatedAt: dbtime.Now(),
Expand All @@ -85,6 +86,17 @@ func WorkspaceBuild(t testing.TB, db database.Store, ws database.Workspace, seed
TraceMetadata: pqtype.NullRawMessage{},
})
require.NoError(t, err, "insert job")
err = db.UpdateProvisionerJobWithCompleteByID(ctx, database.UpdateProvisionerJobWithCompleteByIDParams{
ID: job.ID,
UpdatedAt: dbtime.Now(),
Error: sql.NullString{},
ErrorCode: sql.NullString{},
CompletedAt: sql.NullTime{
Time: dbtime.Now(),
Valid: true,
},
})
require.NoError(t, err, "complete job")

// This intentionally fulfills the minimum requirements of the schema.
// Tests can provide a custom version ID if necessary.
Expand Down