8000 chore(enterprise/coderd/license): fix time-related flake in license expiration warning test by johnstcn · Pull Request #15228 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore(enterprise/coderd/license): fix time-related flake in license expiration warning test #15228

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 1 commit into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions enterprise/coderd/license/license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestEntitlements(t *testing.T) {
db := dbmem.New()
db.InsertLicense(context.Background(), database.InsertLicenseParams{
JWT: coderdenttest.GenerateLicense(t, coderdenttest.LicenseOptions{}),
Exp: time.Now().Add(time.Hour),
Exp: dbtime.Now().Add(time.Hour),
})
entitlements, err := license.Entitlements(context.Background(), db, 1, 1, coderdenttest.Keys, empty)
require.NoError(t, err)
Expand All @@ -78,7 +78,7 @@ func TestEntitlements(t *testing.T) {
return f
}(),
}),
Exp: time.Now().Add(time.Hour),
Exp: dbtime.Now().Add(time.Hour),
})
entitlements, err := license.Entitlements(context.Background(), db, 1, 1, coderdenttest.Keys, empty)
require.NoError(t, err)
Expand All @@ -98,10 +98,10 @@ func TestEntitlements(t *testing.T) {
codersdk.FeatureAuditLog: 1,
},

GraceAt: time.Now().Add(-time.Hour),
ExpiresAt: time.Now().Add(time.Hour),
GraceAt: dbtime.Now().Add(-time.Hour),
ExpiresAt: dbtime.Now().Add(time.Hour),
}),
Exp: time.Now().Add(time.Hour),
Exp: dbtime.Now().Add(time.Hour),
})
entitlements, err := license.Entitlements(context.Background(), db, 1, 1, coderdenttest.Keys, all)
require.NoError(t, err)
Expand All @@ -124,10 +124,10 @@ func TestEntitlements(t *testing.T) {
codersdk.FeatureAuditLog: 1,
},

GraceAt: time.Now().AddDate(0, 0, 2),
ExpiresAt: time.Now().AddDate(0, 0, 5),
GraceAt: dbtime.Now().AddDate(0, 0, 2),
ExpiresAt: dbtime.Now().AddDate(0, 0, 5),
}),
Exp: time.Now().AddDate(0, 0, 5),
Exp: dbtime.Now().AddDate(0, 0, 5),
})

entitlements, err := license.Entitlements(context.Background(), db, 1, 1, coderdenttest.Keys, all)
Expand All @@ -153,8 +153,8 @@ func TestEntitlements(t *testing.T) {
codersdk.FeatureAuditLog: 1,
},

GraceAt: time.Now().AddDate(0, 0, 1),
ExpiresAt: time.Now().AddDate(0, 0, 5),
GraceAt: dbtime.Now().AddDate(0, 0, 1),
ExpiresAt: dbtime.Now().AddDate(0, 0, 5),
}),
Exp: time.Now().AddDate(0, 0, 5),
})
Expand Down Expand Up @@ -183,10 +183,10 @@ func TestEntitlements(t *testing.T) {
},

Trial: true,
GraceAt: time.Now().AddDate(0, 0, 8),
ExpiresAt: time.Now().AddDate(0, 0, 5),
GraceAt: dbtime.Now().AddDate(0, 0, 8),
ExpiresAt: dbtime.Now().AddDate(0, 0, 5),
}),
Exp: time.Now().AddDate(0, 0, 5),
Exp: dbtime.Now().AddDate(0, 0, 5),
})

entitlements, err := license.Entitlements(context.Background(), db, 1, 1, coderdenttest.Keys, all)
Expand All @@ -212,10 +212,10 @@ func TestEntitlements(t *testing.T) {
codersdk.FeatureAuditLog: 1,
},

GraceAt: time.Now().AddDate(0, 0, 30),
ExpiresAt: time.Now().AddDate(0, 0, 5),
GraceAt: dbtime.Now().AddDate(0, 0, 30),
ExpiresAt: dbtime.Now().AddDate(0, 0, 5),
}),
Exp: time.Now().AddDate(0, 0, 5),
Exp: dbtime.Now().AddDate(0, 0, 5),
})

entitlements, err := license.Entitlements(context.Background(), db, 1, 1, coderdenttest.Keys, all)
Expand Down
Loading
0