MCPcopy
hub / github.com/helm/helm / TestWaitForJobComplete

Function TestWaitForJobComplete

pkg/kube/statuswait_test.go:453–508  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

451}
452
453func TestWaitForJobComplete(t *testing.T) {
454 t.Parallel()
455 tests := []struct {
456 name string
457 objManifests []string
458 expectErrStrs []string
459 }{
460 {
461 name: "Job is complete",
462 objManifests: []string{jobCompleteManifest},
463 },
464 {
465 name: "Job is not ready",
466 objManifests: []string{jobNoStatusManifest},
467 expectErrStrs: []string{"resource Job/qual/test not ready. status: InProgress", "context deadline exceeded"},
468 },
469 {
470 name: "Job is ready but not complete",
471 objManifests: []string{jobReadyManifest},
472 expectErrStrs: []string{"resource Job/default/ready-not-complete not ready. status: InProgress", "context deadline exceeded"},
473 },
474 }
475
476 for _, tt := range tests {
477 t.Run(tt.name, func(t *testing.T) {
478 t.Parallel()
479 c := newTestClient(t)
480 fakeClient := dynamicfake.NewSimpleDynamicClient(scheme.Scheme)
481 fakeMapper := testutil.NewFakeRESTMapper(
482 batchv1.SchemeGroupVersion.WithKind("Job"),
483 )
484 statusWaiter := statusWaiter{
485 client: fakeClient,
486 restMapper: fakeMapper,
487 }
488 statusWaiter.SetLogger(slog.Default().Handler())
489 objs := getRuntimeObjFromManifests(t, tt.objManifests)
490 for _, obj := range objs {
491 u := obj.(*unstructured.Unstructured)
492 gvr := getGVR(t, fakeMapper, u)
493 err := fakeClient.Tracker().Create(gvr, u, u.GetNamespace())
494 assert.NoError(t, err)
495 }
496 resourceList := getResourceListFromRuntimeObjs(t, c, objs)
497 err := statusWaiter.WaitWithJobs(resourceList, time.Second*3)
498 if tt.expectErrStrs != nil {
499 require.Error(t, err)
500 for _, expectedErrStr := range tt.expectErrStrs {
501 assert.Contains(t, err.Error(), expectedErrStr)
502 }
503 return
504 }
505 assert.NoError(t, err)
506 })
507 }
508}
509
510func TestWatchForReady(t *testing.T) {

Callers

nothing calls this directly

Calls 10

WaitWithJobsMethod · 0.95
newTestClientFunction · 0.85
getGVRFunction · 0.85
ContainsMethod · 0.80
RunMethod · 0.65
SetLoggerMethod · 0.65
CreateMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…