MCPcopy
hub / github.com/redspread/spread / TestBaseDefaultAnnotationsAndLabels

Function TestBaseDefaultAnnotationsAndLabels

pkg/entity/entity_test.go:107–140  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func TestBaseDefaultAnnotationsAndLabels(t *testing.T) {
108 initial := map[string]string{
109 "overwritten": "no",
110 "not-overwritten": "yes",
111 }
112
113 defaults := kube.ObjectMeta{
114 Labels: initial,
115 Annotations: initial,
116 }
117
118 override := map[string]string{
119 "overwritten": "yes",
120 }
121
122 obj := createSecret(randomString(8))
123 obj.GetObjectMeta().SetLabels(override)
124 obj.GetObjectMeta().SetAnnotations(override)
125
126 base, err := newBase(EntityContainer, defaults, "src", []deploy.KubeObject{obj})
127 assert.NoError(t, err, "valid base")
128 assert.True(t, kube.Semantic.DeepEqual(defaults, base.DefaultMeta()), "defaults should have not changed")
129
130 objects := base.Objects()
131 assert.Len(t, objects, 1)
132
133 expected := initial
134 expected["overwritten"] = "yes"
135
136 output := objects[0]
137 meta := output.GetObjectMeta()
138 assert.Equal(t, expected, meta.GetLabels(), "labels should match")
139 assert.Equal(t, expected, meta.GetAnnotations(), "annotations should match")
140}
141
142func TestBaseNoDefaultAnnotationsAndLabels(t *testing.T) {
143 defaults := kube.ObjectMeta{}

Callers

nothing calls this directly

Calls 7

newBaseFunction · 0.85
createSecretFunction · 0.70
randomStringFunction · 0.70
DefaultMetaMethod · 0.65
ObjectsMethod · 0.65
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected