Skip to content

chore: fix flake in templates_test.go #10875

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
Nov 27, 2023
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
chore: fix flake in templates_test.go
  • Loading branch information
deansheather committed Nov 27, 2023
commit 7ab6bae0766ffcb05347abdbdd5c22ff9b6e2247
14 changes: 14 additions & 0 deletions coderd/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ func TestPatchTemplateMeta(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
// It is unfortunate we need to sleep, but the test can fail if the
// updatedAt is too close together.
time.Sleep(time.Millisecond * 5)

req := codersdk.UpdateTemplateMeta{
DeprecationMessage: ptr.Ref("APGL cannot deprecate"),
Expand All @@ -550,6 +553,9 @@ func TestPatchTemplateMeta(t *testing.T) {
client, tplAdmin := coderdtest.CreateAnotherUser(t, owner, user.OrganizationID, rbac.RoleTemplateAdmin())
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
// It is unfortunate we need to sleep, but the test can fail if the
// updatedAt is too close together.
time.Sleep(time.Millisecond * 5)

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
Expand Down Expand Up @@ -587,6 +593,10 @@ func TestPatchTemplateMeta(t *testing.T) {
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID, func(ctr *codersdk.CreateTemplateRequest) {
ctr.DefaultTTLMillis = ptr.Ref(24 * time.Hour.Milliseconds())
})
// It is unfortunate we need to sleep, but the test can fail if the
// updatedAt is too close together.
time.Sleep(time.Millisecond * 5)

req := codersdk.UpdateTemplateMeta{
DefaultTTLMillis: 0,
}
Expand Down Expand Up @@ -618,6 +628,10 @@ func TestPatchTemplateMeta(t *testing.T) {
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID, func(ctr *codersdk.CreateTemplateRequest) {
ctr.DefaultTTLMillis = ptr.Ref(24 * time.Hour.Milliseconds())
})
// It is unfortunate we need to sleep, but the test can fail if the
// updatedAt is too close together.
time.Sleep(time.Millisecond * 5)

req := codersdk.UpdateTemplateMeta{
DefaultTTLMillis: -1,
}
Expand Down