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

Function TestGetPodList

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

Source from the content-addressed store, hash-verified

33)
34
35func TestGetPodList(t *testing.T) {
36 labelSet := map[string]string{"test": "selector"}
37 tests := []struct {
38 name string
39
40 podList *corev1.PodList
41 watching []watch.Event
42 sortBy func([]*corev1.Pod) sort.Interface
43
44 expected *corev1.PodList
45 expectedNum int
46 expectedErr bool
47 }{
48 {
49 name: "kubectl logs - two ready pods",
50 podList: newPodList(2, -1, -1, labelSet),
51 sortBy: func(pods []*corev1.Pod) sort.Interface { return podutils.ByLogging(pods) },
52 expected: &corev1.PodList{
53 ListMeta: metav1.ListMeta{
54 ResourceVersion: "3", // Two objects created, initial value is 1.
55 },
56 Items: []corev1.Pod{
57 {
58 ObjectMeta: metav1.ObjectMeta{
59 Name: "pod-1",
60 Namespace: metav1.NamespaceDefault,
61 CreationTimestamp: metav1.Date(2016, time.April, 1, 1, 0, 0, 0, time.UTC),
62 Labels: map[string]string{"test": "selector"},
63 },
64 Status: corev1.PodStatus{
65 Conditions: []corev1.PodCondition{
66 {
67 Status: corev1.ConditionTrue,
68 Type: corev1.PodReady,
69 },
70 },
71 },
72 },
73 {
74 ObjectMeta: metav1.ObjectMeta{
75 Name: "pod-2",
76 Namespace: metav1.NamespaceDefault,
77 CreationTimestamp: metav1.Date(2016, time.April, 1, 1, 0, 1, 0, time.UTC),
78 Labels: map[string]string{"test": "selector"},
79 },
80 Status: corev1.PodStatus{
81 Conditions: []corev1.PodCondition{
82 {
83 Status: corev1.ConditionTrue,
84 Type: corev1.PodReady,
85 },
86 },
87 },
88 },
89 },
90 },
91 expectedNum: 2,
92 },

Callers

nothing calls this directly

Calls 5

ByLoggingTypeAlias · 0.92
newPodListFunction · 0.85
GetPodListFunction · 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…