From 1fd6ab04f80300c000638c23ce2a57642e8cc199 Mon Sep 17 00:00:00 2001
From: Felix Kunde <felix-kunde@gmx.de>
Date: Thu, 15 Apr 2021 17:11:28 +0200
Subject: [PATCH] add inherited annotation to unit test

---
 pkg/cluster/sync_test.go | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/pkg/cluster/sync_test.go b/pkg/cluster/sync_test.go
index 10c015ed..e6f23914 100644
--- a/pkg/cluster/sync_test.go
+++ b/pkg/cluster/sync_test.go
@@ -33,11 +33,13 @@ func TestSyncStatefulSetsAnnotations(t *testing.T) {
 	client, _ := newFakeK8sSyncClient()
 	clusterName := "acid-test-cluster"
 	namespace := "default"
+	inheritedAnnotation := "environment"
 
 	pg := acidv1.Postgresql{
 		ObjectMeta: metav1.ObjectMeta{
-			Name:      clusterName,
-			Namespace: namespace,
+			Name:        clusterName,
+			Namespace:   namespace,
+			Annotations: map[string]string{inheritedAnnotation: "test"},
 		},
 		Spec: acidv1.PostgresSpec{
 			Volume: acidv1.Volume{
@@ -57,6 +59,7 @@ func TestSyncStatefulSetsAnnotations(t *testing.T) {
 					DefaultCPULimit:       "300m",
 					DefaultMemoryRequest:  "300Mi",
 					DefaultMemoryLimit:    "300Mi",
+					InheritedAnnotations:  []string{inheritedAnnotation},
 					PodRoleLabel:          "spilo-role",
 					ResourceCheckInterval: time.Duration(3),
 					ResourceCheckTimeout:  time.Duration(10),
@@ -104,4 +107,9 @@ func TestSyncStatefulSetsAnnotations(t *testing.T) {
 	if !cmp.match {
 		t.Errorf("%s: current and desired statefulsets are not matching %#v", testName, cmp)
 	}
+
+	// check if inherited annotation exists
+	if _, exists := desiredSts.Annotations[inheritedAnnotation]; !exists {
+		t.Errorf("%s: inherited annotation not found in desired statefulset: %#v", testName, desiredSts.Annotations)
+	}
 }
-- 
GitLab