MCPcopy Index your code
hub / github.com/coder/coder / AwaitTemplateVersionJobRunning

Function AwaitTemplateVersionJobRunning

coderd/coderdtest/coderdtest.go:1175–1202  ·  view source on GitHub ↗

AwaitTemplateVersionJobRunning waits for the build to be picked up by a provisioner.

(t testing.TB, client *codersdk.Client, version uuid.UUID)

Source from the content-addressed store, hash-verified

1173
1174// AwaitTemplateVersionJobRunning waits for the build to be picked up by a provisioner.
1175func AwaitTemplateVersionJobRunning(t testing.TB, client *codersdk.Client, version uuid.UUID) codersdk.TemplateVersion {
1176 t.Helper()
1177
1178 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
1179 defer cancel()
1180
1181 t.Logf("waiting for template version %s build job to start", version)
1182 var templateVersion codersdk.TemplateVersion
1183 require.Eventually(t, func() bool {
1184 var err error
1185 templateVersion, err = client.TemplateVersion(ctx, version)
1186 if err != nil {
1187 return false
1188 }
1189 t.Logf("template version job status: %s", templateVersion.Job.Status)
1190 switch templateVersion.Job.Status {
1191 case codersdk.ProvisionerJobPending:
1192 return false
1193 case codersdk.ProvisionerJobRunning:
1194 return true
1195 default:
1196 t.FailNow()
1197 return false
1198 }
1199 }, testutil.WaitShort, testutil.IntervalFast, "make sure you set `IncludeProvisionerDaemon`!")
1200 t.Logf("template version %s job has started", version)
1201 return templateVersion
1202}
1203
1204// AwaitTemplateVersionJobCompleted waits for the build to be completed. This may result
1205// from cancelation, an error, or from completing successfully.

Callers 1

Calls 4

FailNowMethod · 0.80
HelperMethod · 0.65
LogfMethod · 0.65
TemplateVersionMethod · 0.65

Tested by 1