MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / TestLabels

Function TestLabels

internal/initialize/metadata_test.go:42–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestLabels(t *testing.T) {
43 // Ignores nil interface.
44 initialize.Labels(nil)
45
46 pod := new(corev1.Pod)
47
48 // Starts nil.
49 assert.Assert(t, pod.Labels == nil)
50
51 // Gets initialized.
52 initialize.Labels(pod)
53 assert.DeepEqual(t, pod.Labels, map[string]string{})
54
55 // Now writable.
56 pod.Labels["x"] = "y"
57
58 // Doesn't overwrite.
59 initialize.Labels(pod)
60 assert.DeepEqual(t, pod.Labels, map[string]string{"x": "y"})
61
62 // Works with PodTemplate, too.
63 template := new(corev1.PodTemplate)
64 initialize.Labels(template)
65 assert.DeepEqual(t, template.Labels, map[string]string{})
66}

Callers

nothing calls this directly

Calls 1

LabelsFunction · 0.92

Tested by

no test coverage detected