Skip to content
Merged
Changes from 1 commit
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
Next Next commit
fix: wait for template version job
  • Loading branch information
mtojek committed Sep 13, 2023
commit 19b352e271d494f3d2c21ef9dc10638e39b17fd0
8 changes: 7 additions & 1 deletion coderd/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ 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)
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)

req := codersdk.UpdateTemplateMeta{
Name: "new-template-name",
DisplayName: "Displayed Name 456",
Expand All @@ -483,6 +485,7 @@ func TestPatchTemplateMeta(t *testing.T) {
DefaultTTLMillis: 12 * time.Hour.Milliseconds(),
AllowUserCancelWorkspaceJobs: false,
}

// It is unfortunate we need to sleep, but the test can fail if the
// updatedAt is too close together.
time.Sleep(time.Millisecond * 5)
Expand Down Expand Up @@ -524,6 +527,7 @@ 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())
})

req := codersdk.UpdateTemplateMeta{
DefaultTTLMillis: 0,
}
Expand Down Expand Up @@ -553,6 +557,7 @@ 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())
})

req := codersdk.UpdateTemplateMeta{
DefaultTTLMillis: -1,
}
Expand Down Expand Up @@ -764,7 +769,7 @@ func TestPatchTemplateMeta(t *testing.T) {
ctr.TimeTilDormantMillis = ptr.Ref(0 * time.Hour.Milliseconds())
ctr.TimeTilDormantAutoDeleteMillis = ptr.Ref(0 * time.Hour.Milliseconds())
})

q
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()

Expand Down Expand Up @@ -819,6 +824,7 @@ 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())
})

require.Equal(t, allowAutostart.Load(), template.AllowUserAutostart)
require.Equal(t, allowAutostop.Load(), template.AllowUserAutostop)

Expand Down