From cbdc937ed26fc7551470cf0b79e8373f9af67928 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Wed, 3 Apr 2024 20:25:28 +0200
Subject: [PATCH] OZG-3328 combine some helm tests and renamed some helm test
 suites

---
 .../helm/configmap_bindings_type_test.yaml    |  2 +
 run_helm_test.sh                              |  3 +-
 ...eployment_container_other_values_test.yaml | 50 -------------------
 ...loyment_pod_default_spec_values_test.yaml} | 16 +++++-
 ...nt_basic_value_and_default_spec_test.yaml} |  0
 src/test/helm/network_policy_test.yaml        |  2 -
 src/test/helm/service_monitor_test.yaml       |  2 +-
 src/test/helm/service_test.yaml               | 10 +++-
 8 files changed, 27 insertions(+), 58 deletions(-)
 delete mode 100644 src/test/helm/deployment_container_other_values_test.yaml
 rename src/test/helm/{deployment_pod_general_values_test.yaml => deployment_pod_default_spec_values_test.yaml} (74%)
 rename src/test/helm/{deyploment_general_value_test.yaml => deyploment_basic_value_and_default_spec_test.yaml} (100%)

diff --git a/nachrichten-bayernid-proxy/src/test/helm/configmap_bindings_type_test.yaml b/nachrichten-bayernid-proxy/src/test/helm/configmap_bindings_type_test.yaml
index 78236b320..e097f3b15 100644
--- a/nachrichten-bayernid-proxy/src/test/helm/configmap_bindings_type_test.yaml
+++ b/nachrichten-bayernid-proxy/src/test/helm/configmap_bindings_type_test.yaml
@@ -33,6 +33,8 @@ tests:
     asserts:
       - isKind:
           of: ConfigMap
+      - isAPIVersion:
+          of: v1
       - equal:
           path: metadata.name
           value: bindings-type
diff --git a/run_helm_test.sh b/run_helm_test.sh
index 08bccc2c0..2bae426e6 100755
--- a/run_helm_test.sh
+++ b/run_helm_test.sh
@@ -5,5 +5,4 @@ set -x
 
 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/**/*test.yaml'  .
-
+cd src/main/helm && helm unittest -f '../../test/helm/**/*test.yaml'  .
\ No newline at end of file
diff --git a/src/test/helm/deployment_container_other_values_test.yaml b/src/test/helm/deployment_container_other_values_test.yaml
deleted file mode 100644
index 092139f30..000000000
--- a/src/test/helm/deployment_container_other_values_test.yaml
+++ /dev/null
@@ -1,50 +0,0 @@
-   
-   #
-# Copyright (C) 2024 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.
-#
-
-suite: test deployment container other values
-release:
-  name: vorgang-manager
-  namespace: sh-helm-test
-templates:
-  - templates/deployment.yaml
-set:
-  ozgcloud:
-    environment: dev
-  imagePullSecret: test-image-pull-secret
-tests:
-  - it: should have correct values for container terminationMessagePolicy, terminationMessagePath, stdin, tty
-    asserts:
-      - equal:
-          path: spec.template.spec.containers[0].terminationMessagePolicy
-          value: File
-      - equal:
-          path: spec.template.spec.containers[0].terminationMessagePath
-          value: /dev/termination-log
-      - equal: 
-          path: spec.template.spec.containers[0].stdin
-          value: true
-      - equal: 
-          path: spec.template.spec.containers[0].tty
-          value: true
\ No newline at end of file
diff --git a/src/test/helm/deployment_pod_general_values_test.yaml b/src/test/helm/deployment_pod_default_spec_values_test.yaml
similarity index 74%
rename from src/test/helm/deployment_pod_general_values_test.yaml
rename to src/test/helm/deployment_pod_default_spec_values_test.yaml
index 1b5b4148e..42f5e0771 100644
--- a/src/test/helm/deployment_pod_general_values_test.yaml
+++ b/src/test/helm/deployment_pod_default_spec_values_test.yaml
@@ -48,4 +48,18 @@ tests:
           value: "default-scheduler"
       - equal:
           path: spec.template.spec.terminationGracePeriodSeconds
-          value: 30
\ No newline at end of file
+          value: 30
+ - it: should have correct values for container terminationMessagePolicy, terminationMessagePath, stdin, tty
+   asserts:
+      - equal:
+          path: spec.template.spec.containers[0].terminationMessagePolicy
+          value: File
+      - equal:
+          path: spec.template.spec.containers[0].terminationMessagePath
+          value: /dev/termination-log
+      - equal: 
+          path: spec.template.spec.containers[0].stdin
+          value: true
+      - equal: 
+          path: spec.template.spec.containers[0].tty
+          value: true
\ No newline at end of file
diff --git a/src/test/helm/deyploment_general_value_test.yaml b/src/test/helm/deyploment_basic_value_and_default_spec_test.yaml
similarity index 100%
rename from src/test/helm/deyploment_general_value_test.yaml
rename to src/test/helm/deyploment_basic_value_and_default_spec_test.yaml
diff --git a/src/test/helm/network_policy_test.yaml b/src/test/helm/network_policy_test.yaml
index 5728f2fc1..16661a34b 100644
--- a/src/test/helm/network_policy_test.yaml
+++ b/src/test/helm/network_policy_test.yaml
@@ -35,8 +35,6 @@ tests:
     asserts:
       - isAPIVersion:
           of: networking.k8s.io/v1
-      - isKind:
-          of: NetworkPolicy
 
   - it: should match kind
     set:
diff --git a/src/test/helm/service_monitor_test.yaml b/src/test/helm/service_monitor_test.yaml
index d25ceca7b..8d1a5caad 100644
--- a/src/test/helm/service_monitor_test.yaml
+++ b/src/test/helm/service_monitor_test.yaml
@@ -29,7 +29,7 @@ release:
 templates:
   - templates/service_monitor.yaml
 tests:
-  - it: should have the label component with value vorgang-manager-service-monitor attached
+  - it: should have basic info
     asserts:
       - isKind:
           of: ServiceMonitor
diff --git a/src/test/helm/service_test.yaml b/src/test/helm/service_test.yaml
index 91d545046..6ffb00408 100644
--- a/src/test/helm/service_test.yaml
+++ b/src/test/helm/service_test.yaml
@@ -22,19 +22,25 @@
 # unter der Lizenz sind dem Lizenztext zu entnehmen.
 #
 
-suite: test deployment
+suite: test service
 release:
   name: vorgang-manager
   namespace: sh-helm-test
 templates:
   - templates/service.yaml
 tests:
-  - it: should have the label component with value vorgang-manager-service attached
+  - it: should have basic info
     asserts:
       - isKind:
           of: Service
       - isAPIVersion:
           of: v1
+      - equal:
+          path: metadata.name
+          value: vorgang-manager
+      - equal:
+          path: metadata.namespace
+          value: sh-helm-test
   - it: should be of type ClusterIP
     asserts:
       - equal:
-- 
GitLab