Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c7a624

Browse files
committed
fix test org references, let dbgen choose
1 parent 5a5c725 commit 1c7a624

File tree

1 file changed

+22
-34
lines changed

1 file changed

+22
-34
lines changed

enterprise/coderd/schedule/template_test.go

+22-34
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ func TestTemplateUpdateBuildDeadlines(t *testing.T) {
2828
db, _ := dbtestutil.NewDB(t)
2929

3030
var (
31-
org = dbgen.Organization(t, db, database.Organization{})
3231
quietUser = dbgen.User(t, db, database.User{
3332
Username: "quiet",
3433
})
@@ -39,17 +38,15 @@ func TestTemplateUpdateBuildDeadlines(t *testing.T) {
3938
CreatedBy: quietUser.ID,
4039
})
4140
templateJob = dbgen.ProvisionerJob(t, db, nil, database.ProvisionerJob{
42-
OrganizationID: org.ID,
43-
FileID: file.ID,
44-
InitiatorID: quietUser.ID,
41+
FileID: file.ID,
42+
InitiatorID: quietUser.ID,
4543
Tags: database.StringMap{
4644
"foo": "bar",
4745
},
4846
})
4947
templateVersion = dbgen.TemplateVersion(t, db, database.TemplateVersion{
50-
OrganizationID: org.ID,
51-
CreatedBy: quietUser.ID,
52-
JobID: templateJob.ID,
48+
CreatedBy: quietUser.ID,
49+
JobID: templateJob.ID,
5350
})
5451
)
5552

@@ -204,20 +201,17 @@ func TestTemplateUpdateBuildDeadlines(t *testing.T) {
204201

205202
var (
206203
template = dbgen.Template(t, db, database.Template{
207-
OrganizationID: org.ID,
208204
ActiveVersionID: templateVersion.ID,
209205
CreatedBy: user.ID,
210206
})
211207
ws = dbgen.Workspace(t, db, database.Workspace{
212-
OrganizationID: org.ID,
213-
OwnerID: user.ID,
214-
TemplateID: template.ID,
208+
OwnerID: user.ID,
209+
TemplateID: template.ID,
215210
})
216211
job = dbgen.ProvisionerJob(t, db, nil, database.ProvisionerJob{
217-
OrganizationID: org.ID,
218-
FileID: file.ID,
219-
InitiatorID: user.ID,
220-
Provisioner: database.ProvisionerTypeEcho,
212+
FileID: file.ID,
213+
InitiatorID: user.ID,
214+
Provisioner: database.ProvisionerTypeEcho,
221215
Tags: database.StringMap{
222216
c.name: "yeah",
223217
},
@@ -236,6 +230,7 @@ func TestTemplateUpdateBuildDeadlines(t *testing.T) {
236230
require.NotEmpty(t, wsBuild.ProvisionerState, "provisioner state must not be empty")
237231

238232
acquiredJob, err := db.AcquireProvisionerJob(ctx, database.AcquireProvisionerJobParams{
233+
OrganizationID: job.OrganizationID,
239234
StartedAt: sql.NullTime{
240235
Time: buildTime,
241236
Valid: true,
@@ -324,41 +319,35 @@ func TestTemplateUpdateBuildDeadlinesSkip(t *testing.T) {
324319
db, _ := dbtestutil.NewDB(t)
325320

326321
var (
327-
org = dbgen.Organization(t, db, database.Organization{})
328322
user = dbgen.User(t, db, database.User{})
329323
file = dbgen.File(t, db, database.File{
330324
CreatedBy: user.ID,
331325
})
332326
templateJob = dbgen.ProvisionerJob(t, db, nil, database.ProvisionerJob{
333-
OrganizationID: org.ID,
334-
FileID: file.ID,
335-
InitiatorID: user.ID,
327+
FileID: file.ID,
328+
InitiatorID: user.ID,
336329
Tags: database.StringMap{
337330
"foo": "bar",
338331
},
339332
})
340333
templateVersion = dbgen.TemplateVersion(t, db, database.TemplateVersion{
341-
OrganizationID: org.ID,
342-
CreatedBy: user.ID,
343-
JobID: templateJob.ID,
334+
CreatedBy: user.ID,
335+
JobID: templateJob.ID,
344336
})
345337
template = dbgen.Template(t, db, database.Template{
346-
OrganizationID: org.ID,
347338
ActiveVersionID: templateVersion.ID,
348339
CreatedBy: user.ID,
349340
})
350341
otherTemplate = dbgen.Template(t, db, database.Template{
351-
OrganizationID: org.ID,
352342
ActiveVersionID: templateVersion.ID,
353343
CreatedBy: user.ID,
354344
})
355345
)
356346

357347
// Create a workspace that will be shared by two builds.
358348
ws := dbgen.Workspace(t, db, database.Workspace{
359-
OrganizationID: org.ID,
360-
OwnerID: user.ID,
361-
TemplateID: template.ID,
349+
OwnerID: user.ID,
350+
TemplateID: template.ID,
362351
})
363352

364353
const userQuietHoursSchedule = "CRON_TZ=UTC 0 0 * * *" // midnight UTC
@@ -473,17 +462,15 @@ func TestTemplateUpdateBuildDeadlinesSkip(t *testing.T) {
473462
wsID := b.workspaceID
474463
if wsID == uuid.Nil {
475464
ws := dbgen.Workspace(t, db, database.Workspace{
476-
OrganizationID: org.ID,
477-
OwnerID: user.ID,
478-
TemplateID: b.templateID,
465+
OwnerID: user.ID,
466+
TemplateID: b.templateID,
479467
})
480468
wsID = ws.ID
481469
}
482470
job := dbgen.ProvisionerJob(t, db, nil, database.ProvisionerJob{
483-
OrganizationID: org.ID,
484-
FileID: file.ID,
485-
InitiatorID: user.ID,
486-
Provisioner: database.ProvisionerTypeEcho,
471+
FileID: file.ID,
472+
InitiatorID: user.ID,
473+
Provisioner: database.ProvisionerTypeEcho,
487474
Tags: database.StringMap{
488475
wsID.String(): "yeah",
489476
},
@@ -521,6 +508,7 @@ func TestTemplateUpdateBuildDeadlinesSkip(t *testing.T) {
521508
}
522509

523510
acquiredJob, err := db.AcquireProvisionerJob(ctx, database.AcquireProvisionerJobParams{
511+
OrganizationID: job.OrganizationID,
524512
StartedAt: sql.NullTime{
525513
Time: buildTime,
526514
Valid: true,

0 commit comments

Comments
 (0)