* Part of this function is untestable right now because the helper function events uses the RestClient of the KubeClient. The fake client returns nil. Therefore it's not possible to let events return problems. */
(t *testing.T)
| 69 | The fake client returns nil. Therefore it's not possible to let events return problems. |
| 70 | */ |
| 71 | func TestCreateReport(t *testing.T) { |
| 72 | testCases := []createReportTestCase{ |
| 73 | { |
| 74 | name: "Nothing to report", |
| 75 | wait: true, |
| 76 | kubeNamespaces: []string{"ns1"}, |
| 77 | kubeReplicasets: map[string][]appsv1.ReplicaSet{ |
| 78 | "ns1": { |
| 79 | { |
| 80 | Spec: appsv1.ReplicaSetSpec{}, |
| 81 | }, |
| 82 | }, |
| 83 | }, |
| 84 | }, |
| 85 | { |
| 86 | name: "Error in pods", |
| 87 | wait: true, |
| 88 | kubeNamespaces: []string{"ns1"}, |
| 89 | kubePods: map[string][]k8sv1.Pod{ |
| 90 | "ns1": { |
| 91 | { |
| 92 | ObjectMeta: metav1.ObjectMeta{ |
| 93 | Name: "ErrorPod", |
| 94 | }, |
| 95 | Status: k8sv1.PodStatus{ |
| 96 | Reason: "Error", |
| 97 | }, |
| 98 | }, |
| 99 | }, |
| 100 | }, |
| 101 | kubeEvents: map[string][]k8sv1.Event{ |
| 102 | "ns1": { |
| 103 | { |
| 104 | Type: "Normal", |
| 105 | }, |
| 106 | }, |
| 107 | }, |
| 108 | expectedReport: []*ReportItem{ |
| 109 | { |
| 110 | Name: "Pods", |
| 111 | Problems: []string{fmt.Sprintf(" Pod %s: \n Status: %s \n Created: %s ago\n", ansi.Color("ErrorPod", "white+b"), ansi.Color("Error", "red+b"), ansi.Color("2s", "white+b"))}, |
| 112 | }, |
| 113 | }, |
| 114 | }, |
| 115 | { |
| 116 | name: "Error in replicasets", |
| 117 | wait: true, |
| 118 | kubeNamespaces: []string{"ns1"}, |
| 119 | kubeReplicasets: map[string][]appsv1.ReplicaSet{ |
| 120 | "ns1": { |
| 121 | { |
| 122 | Spec: appsv1.ReplicaSetSpec{ |
| 123 | Replicas: ptr.Int32(4), |
| 124 | }, |
| 125 | Status: appsv1.ReplicaSetStatus{ |
| 126 | Replicas: int32(3), |
| 127 | }, |
| 128 | }, |
nothing calls this directly
no test coverage detected