MCPcopy
hub / github.com/kite-org/kite / TestPodStatusHelpers

Function TestPodStatusHelpers

pkg/utils/pods_test.go:58–110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func TestPodStatusHelpers(t *testing.T) {
59 t.Run("is pod ready", func(t *testing.T) {
60 pod := &corev1.Pod{
61 Status: corev1.PodStatus{
62 Phase: corev1.PodRunning,
63 Conditions: []corev1.PodCondition{
64 {
65 Type: corev1.PodReady,
66 Status: corev1.ConditionTrue,
67 },
68 },
69 },
70 }
71
72 if !IsPodReady(pod) {
73 t.Fatal("IsPodReady() = false, want true")
74 }
75 })
76
77 t.Run("is pod not ready when phase is not running", func(t *testing.T) {
78 pod := &corev1.Pod{
79 Status: corev1.PodStatus{
80 Phase: corev1.PodPending,
81 Conditions: []corev1.PodCondition{
82 {
83 Type: corev1.PodReady,
84 Status: corev1.ConditionTrue,
85 },
86 },
87 },
88 }
89
90 if IsPodReady(pod) {
91 t.Fatal("IsPodReady() = true, want false")
92 }
93 })
94
95 t.Run("is pod error or success", func(t *testing.T) {
96 for _, phase := range []corev1.PodPhase{corev1.PodFailed, corev1.PodSucceeded} {
97 pod := &corev1.Pod{Status: corev1.PodStatus{Phase: phase}}
98 if !IsPodErrorOrSuccess(pod) {
99 t.Fatalf("IsPodErrorOrSuccess(%s) = false, want true", phase)
100 }
101 }
102 })
103
104 t.Run("is pod neither error nor success", func(t *testing.T) {
105 pod := &corev1.Pod{Status: corev1.PodStatus{Phase: corev1.PodRunning}}
106 if IsPodErrorOrSuccess(pod) {
107 t.Fatal("IsPodErrorOrSuccess() = true, want false")
108 }
109 })
110}

Callers

nothing calls this directly

Calls 3

IsPodReadyFunction · 0.85
IsPodErrorOrSuccessFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected