From df67f6a88e4da429c9a7295057491c34ebe9af4c Mon Sep 17 00:00:00 2001
From: OZG-Cloud Team <noreply@ozg-sh.de>
Date: Tue, 27 Feb 2024 14:30:40 +0100
Subject: [PATCH] OZG-4788-move values in unit-values.yaml to unittests itself

---
 run_helm_test.sh                              |  2 +-
 src/test/helm/deployment_bindings_test.yaml   |  2 +
 ...yment_container_security_context_test.yaml |  2 +
 .../helm/deployment_defaults_labels_test.yaml |  2 +
 src/test/helm/deployment_env_test.yaml        |  4 +-
 .../helm/deployment_host_aliases_test.yaml    |  3 ++
 .../deployment_imagepull_secret_test.yaml     |  2 +
 src/test/helm/deployment_resources_test.yaml  |  2 +
 .../helm/deployment_routing-strategy.yaml     |  1 +
 .../helm/deployment_service_account_test.yaml |  3 ++
 .../helm/deployment_springProfile_test.yaml   |  3 ++
 src/test/helm/deployment_test.yaml            |  2 +
 src/test/helm/ingress-create-or-not.yaml      |  5 +++
 src/test/helm/ingress-nginx-tests.yaml        |  5 +++
 src/test/helm/ingress_test.yaml               |  3 ++
 src/test/unit-values.yaml                     | 38 -------------------
 xta-adapter/run_helm_test.sh                  |  6 +--
 .../helm-linter-values.yaml}                  |  0
 .../helm/cronjob_service_account_test.yaml    |  2 +
 .../src/test/helm/values/unit-values.yaml     | 28 --------------
 .../test/helm/xta_adapter_bindings_test.yaml  |  2 +
 .../helm/xta_adapter_cronjob_basic_test.yaml  |  5 ++-
 ...xta_adapter_cronjob_dummy_probes_test.yaml |  2 +
 .../helm/xta_adapter_cronjob_env_test.yaml    |  2 +
 .../xta_adapter_cronjob_image_pull_test.yaml  |  4 ++
 .../xta_adapter_cronjob_resources_test.yaml   |  2 +
 .../xta_adapter_cronjob_volumes_test.yaml     |  2 +
 27 files changed, 60 insertions(+), 74 deletions(-)
 delete mode 100644 src/test/unit-values.yaml
 rename xta-adapter/src/{main/helm/test-values.yaml => test/helm-linter-values.yaml} (100%)
 delete mode 100644 xta-adapter/src/test/helm/values/unit-values.yaml

diff --git a/run_helm_test.sh b/run_helm_test.sh
index 76ae9ac8..3e37c7fc 100755
--- a/run_helm_test.sh
+++ b/run_helm_test.sh
@@ -4,4 +4,4 @@ set -e
 
 helm template  ./src/main/helm/ -f src/test/helm-linter-values.yaml
 helm lint -f src/test/helm-linter-values.yaml ./src/main/helm/
-cd src/main/helm && helm unittest -f '../../test/helm/*.yaml' -v '../../test/unit-values.yaml' .
\ No newline at end of file
+cd src/main/helm && helm unittest -f '../../test/helm/*.yaml' .
\ No newline at end of file
diff --git a/src/test/helm/deployment_bindings_test.yaml b/src/test/helm/deployment_bindings_test.yaml
index a8019796..9b3f6806 100644
--- a/src/test/helm/deployment_bindings_test.yaml
+++ b/src/test/helm/deployment_bindings_test.yaml
@@ -25,6 +25,8 @@
 suite: deployment bindings
 templates:
   - templates/deployment.yaml
+set:
+  ozgcloud.environment: test
 tests:
   - it: should have temp-dir volume
     asserts:
diff --git a/src/test/helm/deployment_container_security_context_test.yaml b/src/test/helm/deployment_container_security_context_test.yaml
index 18a74503..a68002ce 100644
--- a/src/test/helm/deployment_container_security_context_test.yaml
+++ b/src/test/helm/deployment_container_security_context_test.yaml
@@ -28,6 +28,8 @@ release:
   namespace: sh-helm-test
 templates:
   - templates/deployment.yaml
+set:
+  ozgcloud.environment: test
 tests:
   - it: check default values
     asserts:
diff --git a/src/test/helm/deployment_defaults_labels_test.yaml b/src/test/helm/deployment_defaults_labels_test.yaml
index d6952edf..e5688f08 100644
--- a/src/test/helm/deployment_defaults_labels_test.yaml
+++ b/src/test/helm/deployment_defaults_labels_test.yaml
@@ -30,6 +30,8 @@ templates:
   - templates/deployment.yaml
   - templates/service_monitor.yaml
   - templates/service.yaml
+set:
+  ozgcloud.environment: test
 tests:
   - it: check default labels
     asserts:
diff --git a/src/test/helm/deployment_env_test.yaml b/src/test/helm/deployment_env_test.yaml
index c76bf80b..fbc35ac5 100644
--- a/src/test/helm/deployment_env_test.yaml
+++ b/src/test/helm/deployment_env_test.yaml
@@ -25,6 +25,8 @@
 suite: test environments
 templates:
   - templates/deployment.yaml
+set:
+  ozgcloud.environment: test
 tests:
   - it: check customList
     template: deployment.yaml
@@ -39,8 +41,6 @@ tests:
             name: my_test_environment_name
             value: "A test value"
   - it: check customList test value is not set by default
-    set:
-      ozgcloud.environment: test
     template: deployment.yaml
     asserts:
       - notContains:
diff --git a/src/test/helm/deployment_host_aliases_test.yaml b/src/test/helm/deployment_host_aliases_test.yaml
index 689bf6fd..5bd226ad 100644
--- a/src/test/helm/deployment_host_aliases_test.yaml
+++ b/src/test/helm/deployment_host_aliases_test.yaml
@@ -28,6 +28,9 @@ release:
   namespace: sh-helm-test
 templates:
   - templates/deployment.yaml
+
+set:
+  ozgcloud.environment: test
 tests:
   - it: should not set hostAliases
     asserts:
diff --git a/src/test/helm/deployment_imagepull_secret_test.yaml b/src/test/helm/deployment_imagepull_secret_test.yaml
index 2c72debd..e48100c1 100644
--- a/src/test/helm/deployment_imagepull_secret_test.yaml
+++ b/src/test/helm/deployment_imagepull_secret_test.yaml
@@ -28,6 +28,8 @@ release:
   namespace: sh-helm-test
 templates:
   - templates/deployment.yaml
+set:
+  ozgcloud.environment: test
 tests:
   - it: should use default imagePull secret
     asserts:
diff --git a/src/test/helm/deployment_resources_test.yaml b/src/test/helm/deployment_resources_test.yaml
index 744cc072..e945125e 100644
--- a/src/test/helm/deployment_resources_test.yaml
+++ b/src/test/helm/deployment_resources_test.yaml
@@ -27,6 +27,8 @@ release:
   name: afm-adapter
 templates:
   - templates/deployment.yaml
+set:
+  ozgcloud.environment: test
 tests:
   - it: test resources
     set:
diff --git a/src/test/helm/deployment_routing-strategy.yaml b/src/test/helm/deployment_routing-strategy.yaml
index ff18c1c8..72d20468 100644
--- a/src/test/helm/deployment_routing-strategy.yaml
+++ b/src/test/helm/deployment_routing-strategy.yaml
@@ -30,6 +30,7 @@ templates:
   - deployment.yaml
 set:
   image.tag: latest
+  ozgcloud.environment: test
 tests:
   - it: validate default routing values without questions.yaml
     asserts:
diff --git a/src/test/helm/deployment_service_account_test.yaml b/src/test/helm/deployment_service_account_test.yaml
index 43aa6fcf..1c3b8a40 100644
--- a/src/test/helm/deployment_service_account_test.yaml
+++ b/src/test/helm/deployment_service_account_test.yaml
@@ -28,6 +28,9 @@ release:
   namespace: sh-helm-test
 templates:
   - templates/deployment.yaml
+
+set:
+  ozgcloud.environment: test
 tests:
   - it: should use afm-adapter service account name
     set:
diff --git a/src/test/helm/deployment_springProfile_test.yaml b/src/test/helm/deployment_springProfile_test.yaml
index dcdccb80..446ce8f4 100644
--- a/src/test/helm/deployment_springProfile_test.yaml
+++ b/src/test/helm/deployment_springProfile_test.yaml
@@ -27,6 +27,7 @@ release:
   name: if-adapter
 templates:
   - templates/deployment.yaml
+
 tests:
   - it: should override spring profiles
     set:
@@ -40,6 +41,8 @@ tests:
             name: spring_profiles_active
             value: oc,stage,ea
   - it: should generate spring profiles
+    set:
+      ozgcloud.environment: test
     asserts:
       - isKind:
           of: Deployment
diff --git a/src/test/helm/deployment_test.yaml b/src/test/helm/deployment_test.yaml
index ca8169b6..7edba4d7 100644
--- a/src/test/helm/deployment_test.yaml
+++ b/src/test/helm/deployment_test.yaml
@@ -28,6 +28,8 @@ release:
   namespace: sh-helm-test
 templates:
   - deployment.yaml
+set:
+  ozgcloud.environment: test
 tests:
   - it: validate image type and container image
     asserts:
diff --git a/src/test/helm/ingress-create-or-not.yaml b/src/test/helm/ingress-create-or-not.yaml
index 7bf967dd..fa92ab46 100644
--- a/src/test/helm/ingress-create-or-not.yaml
+++ b/src/test/helm/ingress-create-or-not.yaml
@@ -25,6 +25,11 @@
 suite: test ingress creation dependent from values
 templates:
   - templates/ingress.yaml
+
+set:
+  ozgcloud:
+    bezeichner: helm
+    
 tests:
   - it: create ingress by config
     set:
diff --git a/src/test/helm/ingress-nginx-tests.yaml b/src/test/helm/ingress-nginx-tests.yaml
index ea2c4874..7aa49a0e 100644
--- a/src/test/helm/ingress-nginx-tests.yaml
+++ b/src/test/helm/ingress-nginx-tests.yaml
@@ -25,6 +25,11 @@
 suite: test ingress options
 templates:
   - templates/ingress.yaml
+
+set:
+  ozgcloud:
+    bezeichner: helm
+    
 tests:
   - it: should create afm ingress tls
     release:
diff --git a/src/test/helm/ingress_test.yaml b/src/test/helm/ingress_test.yaml
index e5086079..87c314c0 100644
--- a/src/test/helm/ingress_test.yaml
+++ b/src/test/helm/ingress_test.yaml
@@ -28,6 +28,9 @@ release:
   namespace: sh-helm-test
 templates:
   - templates/ingress.yaml
+set:
+  ozgcloud:
+    bezeichner: helm
 tests:
   - it: should match basic data
     asserts:
diff --git a/src/test/unit-values.yaml b/src/test/unit-values.yaml
deleted file mode 100644
index 4c105880..00000000
--- a/src/test/unit-values.yaml
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Copyright (C) 2022 Das Land Schleswig-Holstein vertreten durch den
-# Ministerpräsidenten des Landes Schleswig-Holstein
-# Staatskanzlei
-# Abteilung Digitalisierung und zentrales IT-Management der Landesregierung
-#
-# Lizenziert unter der EUPL, Version 1.2 oder - sobald
-# diese von der Europäischen Kommission genehmigt wurden -
-# Folgeversionen der EUPL ("Lizenz");
-# Sie dürfen dieses Werk ausschließlich gemäß
-# dieser Lizenz nutzen.
-# Eine Kopie der Lizenz finden Sie hier:
-#
-# https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
-#
-# Sofern nicht durch anwendbare Rechtsvorschriften
-# gefordert oder in schriftlicher Form vereinbart, wird
-# die unter der Lizenz verbreitete Software "so wie sie
-# ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN -
-# ausdrücklich oder stillschweigend - verbreitet.
-# Die sprachspezifischen Genehmigungen und Beschränkungen
-# unter der Lizenz sind dem Lizenztext zu entnehmen.
-#
-
-baseUrl: test.sh.ozg-cloud.de
-
-ozgcloud:
-  bundesland: sh
-  environment: test
-  bezeichner: helm
-
-routing:
-  targetVorgangManagerName: vorgang-manager
-
-image:
-  repo: docker.ozg-sh.de
-  name: intelliform-adapter
-  tag: latest
diff --git a/xta-adapter/run_helm_test.sh b/xta-adapter/run_helm_test.sh
index 8cfc4201..9a57c3aa 100755
--- a/xta-adapter/run_helm_test.sh
+++ b/xta-adapter/run_helm_test.sh
@@ -2,6 +2,6 @@
 
 set -e
 
-helm template  ./src/main/helm/ -f src/main/helm/test-values.yaml
-helm lint -f src/test/helm/values/unit-values.yaml ./src/main/helm/
-cd src/main/helm && helm unittest -f '../../test/helm/*.yaml' -v '../../test/helm/values/unit-values.yaml' .
\ No newline at end of file
+helm template  ./src/main/helm/ -f src/test/helm-linter-values.yaml
+helm lint -f src/test/helm-linter-values.yaml ./src/main/helm/
+cd src/main/helm && helm unittest -f '../../test/helm/*.yaml'  .
diff --git a/xta-adapter/src/main/helm/test-values.yaml b/xta-adapter/src/test/helm-linter-values.yaml
similarity index 100%
rename from xta-adapter/src/main/helm/test-values.yaml
rename to xta-adapter/src/test/helm-linter-values.yaml
diff --git a/xta-adapter/src/test/helm/cronjob_service_account_test.yaml b/xta-adapter/src/test/helm/cronjob_service_account_test.yaml
index 933e2c64..b84278f1 100644
--- a/xta-adapter/src/test/helm/cronjob_service_account_test.yaml
+++ b/xta-adapter/src/test/helm/cronjob_service_account_test.yaml
@@ -28,6 +28,8 @@ templates:
 release:
   name: xta-adapter
   namespace: helm-test
+set: 
+  ozgcloud.environment: test
 tests:
   - it: should use service account with default name
     set:
diff --git a/xta-adapter/src/test/helm/values/unit-values.yaml b/xta-adapter/src/test/helm/values/unit-values.yaml
deleted file mode 100644
index fe20e41e..00000000
--- a/xta-adapter/src/test/helm/values/unit-values.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (C) 2022 Das Land Schleswig-Holstein vertreten durch den
-# Ministerpräsidenten des Landes Schleswig-Holstein
-# Staatskanzlei
-# Abteilung Digitalisierung und zentrales IT-Management der Landesregierung
-#
-# Lizenziert unter der EUPL, Version 1.2 oder - sobald
-# diese von der Europäischen Kommission genehmigt wurden -
-# Folgeversionen der EUPL ("Lizenz");
-# Sie dürfen dieses Werk ausschließlich gemäß
-# dieser Lizenz nutzen.
-# Eine Kopie der Lizenz finden Sie hier:
-#
-# https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
-#
-# Sofern nicht durch anwendbare Rechtsvorschriften
-# gefordert oder in schriftlicher Form vereinbart, wird
-# die unter der Lizenz verbreitete Software "so wie sie
-# ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN -
-# ausdrücklich oder stillschweigend - verbreitet.
-# Die sprachspezifischen Genehmigungen und Beschränkungen
-# unter der Lizenz sind dem Lizenztext zu entnehmen.
-#
-
-ozgcloud:
-  bundesland: sh
-  environment: test
-  bezeichner: helm
\ No newline at end of file
diff --git a/xta-adapter/src/test/helm/xta_adapter_bindings_test.yaml b/xta-adapter/src/test/helm/xta_adapter_bindings_test.yaml
index ef156052..959b0b82 100644
--- a/xta-adapter/src/test/helm/xta_adapter_bindings_test.yaml
+++ b/xta-adapter/src/test/helm/xta_adapter_bindings_test.yaml
@@ -25,6 +25,8 @@
 suite: xta-adapter bindings
 templates:
   - templates/xta_adapter_cronjob.yaml
+set:
+  ozgcloud.environment: test
 tests:
   - it: should have temp-dir volume
     asserts:
diff --git a/xta-adapter/src/test/helm/xta_adapter_cronjob_basic_test.yaml b/xta-adapter/src/test/helm/xta_adapter_cronjob_basic_test.yaml
index 4667b03c..2172150b 100644
--- a/xta-adapter/src/test/helm/xta_adapter_cronjob_basic_test.yaml
+++ b/xta-adapter/src/test/helm/xta_adapter_cronjob_basic_test.yaml
@@ -28,6 +28,9 @@ templates:
 release:
   name: xta-adapter
   namespace: helm-test
+set:
+  ozgcloud.environment: dev  
+  
 tests:
   - it: validate basic data 
     template: xta_adapter_cronjob.yaml
@@ -70,7 +73,6 @@ tests:
     template: xta_adapter_cronjob.yaml
     set:
       image.name: xta-adapter
-      ozgcloud.environment: dev
     asserts:
       - equal:
           path: spec.schedule
@@ -79,7 +81,6 @@ tests:
     template: xta_adapter_cronjob.yaml
     set:
       image.name: xta-adapter
-      ozgcloud.environment: dev
     asserts:
     - equal:
         path: spec.jobTemplate.spec.template.spec.containers[0].image
diff --git a/xta-adapter/src/test/helm/xta_adapter_cronjob_dummy_probes_test.yaml b/xta-adapter/src/test/helm/xta_adapter_cronjob_dummy_probes_test.yaml
index 0a3ef9a9..93637305 100644
--- a/xta-adapter/src/test/helm/xta_adapter_cronjob_dummy_probes_test.yaml
+++ b/xta-adapter/src/test/helm/xta_adapter_cronjob_dummy_probes_test.yaml
@@ -28,6 +28,8 @@ templates:
 release:
   name: xta-adapter
   namespace: helm-test
+set:
+  ozgcloud.environment: test
 tests:
   - it: check dummy livenessProbe default disabled
     template: xta_adapter_cronjob.yaml
diff --git a/xta-adapter/src/test/helm/xta_adapter_cronjob_env_test.yaml b/xta-adapter/src/test/helm/xta_adapter_cronjob_env_test.yaml
index 5e4ca8ae..45eb29fa 100644
--- a/xta-adapter/src/test/helm/xta_adapter_cronjob_env_test.yaml
+++ b/xta-adapter/src/test/helm/xta_adapter_cronjob_env_test.yaml
@@ -28,6 +28,8 @@ templates:
 release:
   name: xta-adapter
   namespace: helm-test
+set: 
+  ozgcloud.environment: test
 tests:
   - it: check default env
     template: xta_adapter_cronjob.yaml
diff --git a/xta-adapter/src/test/helm/xta_adapter_cronjob_image_pull_test.yaml b/xta-adapter/src/test/helm/xta_adapter_cronjob_image_pull_test.yaml
index d74e945a..bf1fb21e 100644
--- a/xta-adapter/src/test/helm/xta_adapter_cronjob_image_pull_test.yaml
+++ b/xta-adapter/src/test/helm/xta_adapter_cronjob_image_pull_test.yaml
@@ -28,8 +28,12 @@ release:
   namespace: sh-helm-test
 templates:
   - templates/xta_adapter_cronjob.yaml
+set: 
+  ozgcloud.environment: dev
+  
 tests:
   - it: should use default imagePull secret
+    set:
     asserts:
       - equal:
           path: spec.jobTemplate.spec.template.spec.imagePullSecrets[0].name
diff --git a/xta-adapter/src/test/helm/xta_adapter_cronjob_resources_test.yaml b/xta-adapter/src/test/helm/xta_adapter_cronjob_resources_test.yaml
index 198021ea..02efe396 100644
--- a/xta-adapter/src/test/helm/xta_adapter_cronjob_resources_test.yaml
+++ b/xta-adapter/src/test/helm/xta_adapter_cronjob_resources_test.yaml
@@ -28,6 +28,8 @@ templates:
 release:
   name: xta-adapter
   namespace: helm-test
+set: 
+  ozgcloud.environment: dev
 tests:
   - it: check resources
     template: xta_adapter_cronjob.yaml
diff --git a/xta-adapter/src/test/helm/xta_adapter_cronjob_volumes_test.yaml b/xta-adapter/src/test/helm/xta_adapter_cronjob_volumes_test.yaml
index 95013323..6acac9f4 100644
--- a/xta-adapter/src/test/helm/xta_adapter_cronjob_volumes_test.yaml
+++ b/xta-adapter/src/test/helm/xta_adapter_cronjob_volumes_test.yaml
@@ -28,6 +28,8 @@ templates:
 release:
   name: xta-adapter
   namespace: helm-test
+set: 
+  ozgcloud.environment: dev
 tests:
   - it: check volume mounts
     template: xta_adapter_cronjob.yaml
-- 
GitLab