MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestClusterEventsProjection

Function TestClusterEventsProjection

controlplane/admin/cluster_test.go:172–198  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

170}
171
172func 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

Callers

nothing calls this directly

Calls 2

clusterTestRouterFunction · 0.85
getJSONFunction · 0.85

Tested by

no test coverage detected