| 40 | } |
| 41 | |
| 42 | func 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 | } |