mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: compute job status as column (#10024)
* chore: provisioner job status as column * use provisioner job status for workspace searching
This commit is contained in:
@@ -328,16 +328,16 @@ func GroupMember(t testing.TB, db database.Store, orig database.GroupMember) dat
|
||||
// ProvisionerJob is a bit more involved to get the values such as "completedAt", "startedAt", "cancelledAt" set. ps
|
||||
// can be set to nil if you are SURE that you don't require a provisionerdaemon to acquire the job in your test.
|
||||
func ProvisionerJob(t testing.TB, db database.Store, ps pubsub.Pubsub, orig database.ProvisionerJob) database.ProvisionerJob {
|
||||
id := takeFirst(orig.ID, uuid.New())
|
||||
jobID := takeFirst(orig.ID, uuid.New())
|
||||
// Always set some tags to prevent Acquire from grabbing jobs it should not.
|
||||
if !orig.StartedAt.Time.IsZero() {
|
||||
if orig.Tags == nil {
|
||||
orig.Tags = make(database.StringMap)
|
||||
}
|
||||
// Make sure when we acquire the job, we only get this one.
|
||||
orig.Tags[id.String()] = "true"
|
||||
orig.Tags[jobID.String()] = "true"
|
||||
}
|
||||
jobID := takeFirst(orig.ID, uuid.New())
|
||||
|
||||
job, err := db.InsertProvisionerJob(genCtx, database.InsertProvisionerJobParams{
|
||||
ID: jobID,
|
||||
CreatedAt: takeFirst(orig.CreatedAt, dbtime.Now()),
|
||||
@@ -365,6 +365,8 @@ func ProvisionerJob(t testing.TB, db database.Store, ps pubsub.Pubsub, orig data
|
||||
WorkerID: uuid.NullUUID{},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// There is no easy way to make sure we acquire the correct job.
|
||||
require.Equal(t, jobID, job.ID, "acquired incorrect job")
|
||||
}
|
||||
|
||||
if !orig.CompletedAt.Time.IsZero() || orig.Error.String != "" {
|
||||
|
||||
Reference in New Issue
Block a user