Skip to content

Commit e74024d

Browse files
committed
Fix tests
1 parent 0422e41 commit e74024d

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

coderd/database/dbfake/dbfake.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
"github.com/google/uuid"
10+
"github.com/sqlc-dev/pqtype"
1011
"github.com/stretchr/testify/require"
1112

1213
"github.com/coder/coder/v2/coderd/database"
@@ -68,15 +69,22 @@ func WorkspaceBuild(t testing.TB, db database.Store, ws database.Workspace, seed
6869
WorkspaceBuildID: seed.ID,
6970
})
7071
require.NoError(t, err)
71-
job := dbgen.ProvisionerJob(t, db, nil, database.ProvisionerJob{
72+
//nolint:gocritic // This is only used by tests.
73+
job, err := db.InsertProvisionerJob(dbauthz.AsSystemRestricted(context.Background()), database.InsertProvisionerJobParams{
7274
ID: jobID,
73-
Input: payload,
75+
CreatedAt: dbtime.Now(),
76+
UpdatedAt: dbtime.Now(),
7477
OrganizationID: ws.OrganizationID,
75-
CompletedAt: sql.NullTime{
76-
Time: dbtime.Now(),
77-
Valid: true,
78-
},
78+
InitiatorID: ws.OwnerID,
79+
Provisioner: database.ProvisionerTypeEcho,
80+
StorageMethod: database.ProvisionerStorageMethodFile,
81+
FileID: uuid.New(),
82+
Type: database.ProvisionerJobTypeWorkspaceBuild,
83+
Input: payload,
84+
Tags: nil,
85+
TraceMetadata: pqtype.NullRawMessage{},
7986
})
87+
require.NoError(t, err, "insert job")
8088

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

coderd/database/dbgen/dbgen.go

+3
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ func ProvisionerJob(t testing.TB, db database.Store, ps pubsub.Pubsub, orig data
395395
require.NoError(t, err)
396396
}
397397

398+
job, err = db.GetProvisionerJobByID(genCtx, jobID)
399+
require.NoError(t, err)
400+
398401
return job
399402
}
400403

0 commit comments

Comments
 (0)