AwaitTemplateVersionJobCompleted waits for the build to be completed. This may result from cancelation, an error, or from completing successfully.
(t testing.TB, client *codersdk.Client, version uuid.UUID)
| 1204 | // AwaitTemplateVersionJobCompleted waits for the build to be completed. This may result |
| 1205 | // from cancelation, an error, or from completing successfully. |
| 1206 | func AwaitTemplateVersionJobCompleted(t testing.TB, client *codersdk.Client, version uuid.UUID) codersdk.TemplateVersion { |
| 1207 | t.Helper() |
| 1208 | |
| 1209 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 1210 | defer cancel() |
| 1211 | |
| 1212 | t.Logf("waiting for template version %s build job to complete", version) |
| 1213 | var templateVersion codersdk.TemplateVersion |
| 1214 | require.Eventually(t, func() bool { |
| 1215 | var err error |
| 1216 | templateVersion, err = client.TemplateVersion(ctx, version) |
| 1217 | t.Logf("template version job status: %s", templateVersion.Job.Status) |
| 1218 | return assert.NoError(t, err) && templateVersion.Job.CompletedAt != nil |
| 1219 | }, testutil.WaitLong, testutil.IntervalFast, "make sure you set `IncludeProvisionerDaemon`!") |
| 1220 | t.Logf("template version %s job has completed", version) |
| 1221 | return templateVersion |
| 1222 | } |
| 1223 | |
| 1224 | // AwaitWorkspaceBuildJobCompleted waits for a workspace provision job to reach completed status. |
| 1225 | func AwaitWorkspaceBuildJobCompleted(t testing.TB, client *codersdk.Client, build uuid.UUID) codersdk.WorkspaceBuild { |