(t *testing.T)
| 170 | } |
| 171 | |
| 172 | func TestClusterEventsProjection(t *testing.T) { |
| 173 | ev := &corev1.Event{ |
| 174 | ObjectMeta: metav1.ObjectMeta{Name: "ev1", Namespace: "duckgres", UID: "ev-uid-1"}, |
| 175 | Reason: "FailedScheduling", |
| 176 | Message: "0/3 nodes are available", |
| 177 | Type: "Warning", |
| 178 | InvolvedObject: corev1.ObjectReference{ |
| 179 | Kind: "Pod", |
| 180 | Name: "worker-abc", |
| 181 | Namespace: "duckgres", |
| 182 | }, |
| 183 | } |
| 184 | e := clusterTestRouter(ev) |
| 185 | body := getJSON(t, e, "/api/v1/cluster/events") |
| 186 | items := body["items"].([]any) |
| 187 | if len(items) != 1 { |
| 188 | t.Fatalf("events: got %d items, want 1", len(items)) |
| 189 | } |
| 190 | evOut := items[0].(map[string]any) |
| 191 | if evOut["reason"] != "FailedScheduling" { |
| 192 | t.Errorf("reason wrong: %v", evOut["reason"]) |
| 193 | } |
| 194 | io := evOut["involvedObject"].(map[string]any) |
| 195 | if io["kind"] != "Pod" || io["name"] != "worker-abc" { |
| 196 | t.Errorf("involvedObject wrong: %v", io) |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | // TestClusterNodesForbiddenDegradesToEmpty asserts an RBAC Forbidden from the |
| 201 | // API server yields a 200 empty list (not a 500) — the view shows nothing rather |
nothing calls this directly
no test coverage detected