MCPcopy
hub / github.com/kubernetes/kubectl / TestGetFirstPod

Function TestGetFirstPod

pkg/polymorphichelpers/helpers_test.go:130–290  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

128 }
129}
130func TestGetFirstPod(t *testing.T) {
131 labelSet := map[string]string{"test": "selector"}
132 tests := []struct {
133 name string
134
135 podList *corev1.PodList
136 watching []watch.Event
137 sortBy func([]*corev1.Pod) sort.Interface
138
139 expected *corev1.Pod
140 expectedNum int
141 expectedErr bool
142 }{
143 {
144 name: "kubectl logs - two ready pods",
145 podList: newPodList(2, -1, -1, labelSet),
146 sortBy: func(pods []*corev1.Pod) sort.Interface { return podutils.ByLogging(pods) },
147 expected: &corev1.Pod{
148 ObjectMeta: metav1.ObjectMeta{
149 Name: "pod-1",
150 Namespace: metav1.NamespaceDefault,
151 CreationTimestamp: metav1.Date(2016, time.April, 1, 1, 0, 0, 0, time.UTC),
152 Labels: map[string]string{"test": "selector"},
153 },
154 Status: corev1.PodStatus{
155 Conditions: []corev1.PodCondition{
156 {
157 Status: corev1.ConditionTrue,
158 Type: corev1.PodReady,
159 },
160 },
161 },
162 },
163 expectedNum: 2,
164 },
165 {
166 name: "kubectl logs - one unhealthy, one healthy",
167 podList: newPodList(2, -1, 1, labelSet),
168 sortBy: func(pods []*corev1.Pod) sort.Interface { return podutils.ByLogging(pods) },
169 expected: &corev1.Pod{
170 ObjectMeta: metav1.ObjectMeta{
171 Name: "pod-2",
172 Namespace: metav1.NamespaceDefault,
173 CreationTimestamp: metav1.Date(2016, time.April, 1, 1, 0, 1, 0, time.UTC),
174 Labels: map[string]string{"test": "selector"},
175 },
176 Status: corev1.PodStatus{
177 Conditions: []corev1.PodCondition{
178 {
179 Status: corev1.ConditionTrue,
180 Type: corev1.PodReady,
181 },
182 },
183 ContainerStatuses: []corev1.ContainerStatus{{RestartCount: 5}},
184 },
185 },
186 expectedNum: 2,
187 },

Callers

nothing calls this directly

Calls 6

ByLoggingTypeAlias · 0.92
ActivePodsTypeAlias · 0.92
newPodListFunction · 0.85
GetFirstPodFunction · 0.85
StringMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…