Skip to content

Commit c11cfbc

Browse files
committed
fix unit tests
1 parent c432d49 commit c11cfbc

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

coderd/database/dbpurge/dbpurge_test.go

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ func TestDeleteOldProvisionerDaemons(t *testing.T) {
203203
t.Parallel()
204204

205205
db, _ := dbtestutil.NewDB(t)
206+
defaultOrg := dbgen.Organization(t, db, database.Organization{})
206207
logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
207208

208209
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
@@ -213,24 +214,26 @@ func TestDeleteOldProvisionerDaemons(t *testing.T) {
213214
// given
214215
_, err := db.UpsertProvisionerDaemon(ctx, database.UpsertProvisionerDaemonParams{
215216
// Provisioner daemon created 14 days ago, and checked in just before 7 days deadline.
216-
Name: "external-0",
217-
Provisioners: []database.ProvisionerType{"echo"},
218-
Tags: database.StringMap{provisionersdk.TagScope: provisionersdk.ScopeOrganization},
219-
CreatedAt: now.Add(-14 * 24 * time.Hour),
220-
LastSeenAt: sql.NullTime{Valid: true, Time: now.Add(-7 * 24 * time.Hour).Add(time.Minute)},
221-
Version: "1.0.0",
222-
APIVersion: proto.CurrentVersion.String(),
217+
Name: "external-0",
218+
Provisioners: []database.ProvisionerType{"echo"},
219+
Tags: database.StringMap{provisionersdk.TagScope: provisionersdk.ScopeOrganization},
220+
CreatedAt: now.Add(-14 * 24 * time.Hour),
221+
LastSeenAt: sql.NullTime{Valid: true, Time: now.Add(-7 * 24 * time.Hour).Add(time.Minute)},
222+
Version: "1.0.0",
223+
APIVersion: proto.CurrentVersion.String(),
224+
OrganizationID: defaultOrg.ID,
223225
})
224226
require.NoError(t, err)
225227
_, err = db.UpsertProvisionerDaemon(ctx, database.UpsertProvisionerDaemonParams{
226228
// Provisioner daemon created 8 days ago, and checked in last time an hour after creation.
227-
Name: "external-1",
228-
Provisioners: []database.ProvisionerType{"echo"},
229-
Tags: database.StringMap{provisionersdk.TagScope: provisionersdk.ScopeOrganization},
230-
CreatedAt: now.Add(-8 * 24 * time.Hour),
231-
LastSeenAt: sql.NullTime{Valid: true, Time: now.Add(-8 * 24 * time.Hour).Add(time.Hour)},
232-
Version: "1.0.0",
233-
APIVersion: proto.CurrentVersion.String(),
229+
Name: "external-1",
230+
Provisioners: []database.ProvisionerType{"echo"},
231+
Tags: database.StringMap{provisionersdk.TagScope: provisionersdk.ScopeOrganization},
232+
CreatedAt: now.Add(-8 * 24 * time.Hour),
233+
LastSeenAt: sql.NullTime{Valid: true, Time: now.Add(-8 * 24 * time.Hour).Add(time.Hour)},
234+
Version: "1.0.0",
235+
APIVersion: proto.CurrentVersion.String(),
236+
OrganizationID: defaultOrg.ID,
234237
})
235238
require.NoError(t, err)
236239
_, err = db.UpsertProvisionerDaemon(ctx, database.UpsertProvisionerDaemonParams{
@@ -241,9 +244,10 @@ func TestDeleteOldProvisionerDaemons(t *testing.T) {
241244
provisionersdk.TagScope: provisionersdk.ScopeUser,
242245
provisionersdk.TagOwner: uuid.NewString(),
243246
},
244-
CreatedAt: now.Add(-9 * 24 * time.Hour),
245-
Version: "1.0.0",
246-
APIVersion: proto.CurrentVersion.String(),
247+
CreatedAt: now.Add(-9 * 24 * time.Hour),
248+
Version: "1.0.0",
249+
APIVersion: proto.CurrentVersion.String(),
250+
OrganizationID: defaultOrg.ID,
247251
})
248252
require.NoError(t, err)
249253
_, err = db.UpsertProvisionerDaemon(ctx, database.UpsertProvisionerDaemonParams{
@@ -254,10 +258,11 @@ func TestDeleteOldProvisionerDaemons(t *testing.T) {
254258
provisionersdk.TagScope: provisionersdk.ScopeUser,
255259
provisionersdk.TagOwner: uuid.NewString(),
256260
},
257-
CreatedAt: now.Add(-6 * 24 * time.Hour),
258-
LastSeenAt: sql.NullTime{Valid: true, Time: now.Add(-6 * 24 * time.Hour)},
259-
Version: "1.0.0",
260-
APIVersion: proto.CurrentVersion.String(),
261+
CreatedAt: now.Add(-6 * 24 * time.Hour),
262+
LastSeenAt: sql.NullTime{Valid: true, Time: now.Add(-6 * 24 * time.Hour)},
263+
Version: "1.0.0",
264+
APIVersion: proto.CurrentVersion.String(),
265+
OrganizationID: defaultOrg.ID,
261266
})
262267
require.NoError(t, err)
263268

0 commit comments

Comments
 (0)