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

Function TestWatchResourceWatchEvents

pkg/cmd/get/get_test.go:2474–2775  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2472}
2473
2474func TestWatchResourceWatchEvents(t *testing.T) {
2475
2476 testcases := []struct {
2477 format string
2478 table bool
2479 expected string
2480 }{
2481 {
2482 format: "",
2483 expected: `EVENT NAMESPACE NAME AGE
2484ADDED test pod/bar <unknown>
2485ADDED test pod/foo <unknown>
2486MODIFIED test pod/foo <unknown>
2487DELETED test pod/foo <unknown>
2488`,
2489 },
2490 {
2491 format: "",
2492 table: true,
2493 expected: `EVENT NAMESPACE NAME READY STATUS RESTARTS AGE
2494ADDED test pod/bar 0/0 0 <unknown>
2495ADDED test pod/foo 0/0 0 <unknown>
2496MODIFIED test pod/foo 0/0 0 <unknown>
2497DELETED test pod/foo 0/0 0 <unknown>
2498`,
2499 },
2500 {
2501 format: "wide",
2502 table: true,
2503 expected: `EVENT NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
2504ADDED test pod/bar 0/0 0 <unknown> <none> <none> <none> <none>
2505ADDED test pod/foo 0/0 0 <unknown> <none> <none> <none> <none>
2506MODIFIED test pod/foo 0/0 0 <unknown> <none> <none> <none> <none>
2507DELETED test pod/foo 0/0 0 <unknown> <none> <none> <none> <none>
2508`,
2509 },
2510 {
2511 format: "json",
2512 expected: `{"type":"ADDED","object":{"apiVersion":"v1","kind":"Pod","metadata":{"name":"bar","namespace":"test","resourceVersion":"9"},"spec":{"containers":null,"dnsPolicy":"ClusterFirst","enableServiceLinks":true,"restartPolicy":"Always","securityContext":{},"terminationGracePeriodSeconds":30},"status":{}}}
2513{"type":"ADDED","object":{"apiVersion":"v1","kind":"Pod","metadata":{"name":"foo","namespace":"test","resourceVersion":"10"},"spec":{"containers":null,"dnsPolicy":"ClusterFirst","enableServiceLinks":true,"restartPolicy":"Always","securityContext":{},"terminationGracePeriodSeconds":30},"status":{}}}
2514{"type":"MODIFIED","object":{"apiVersion":"v1","kind":"Pod","metadata":{"name":"foo","namespace":"test","resourceVersion":"11"},"spec":{"containers":null,"dnsPolicy":"ClusterFirst","enableServiceLinks":true,"restartPolicy":"Always","securityContext":{},"terminationGracePeriodSeconds":30},"status":{}}}
2515{"type":"DELETED","object":{"apiVersion":"v1","kind":"Pod","metadata":{"name":"foo","namespace":"test","resourceVersion":"12"},"spec":{"containers":null,"dnsPolicy":"ClusterFirst","enableServiceLinks":true,"restartPolicy":"Always","securityContext":{},"terminationGracePeriodSeconds":30},"status":{}}}
2516`,
2517 },
2518 {
2519 format: "yaml",
2520 expected: `object:
2521 apiVersion: v1
2522 kind: Pod
2523 metadata:
2524 name: bar
2525 namespace: test
2526 resourceVersion: "9"
2527 spec:
2528 containers: null
2529 dnsPolicy: ClusterFirst
2530 enableServiceLinks: true
2531 restartPolicy: Always

Callers

nothing calls this directly

Calls 10

watchTestDataFunction · 0.85
podTableWatchBodyFunction · 0.85
watchBodyFunction · 0.85
podTableObjBodyFunction · 0.85
NewCmdGetFunction · 0.85
WithNamespaceMethod · 0.80
CleanupMethod · 0.80
GetMethod · 0.65
StringMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…