From 739c82438d1a0d5c609c7acf493a6ca561e86b99 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Thu, 24 Oct 2024 09:13:07 +0200 Subject: [PATCH] Add some unit tests for namespaces --- tests/namespaces_test.yaml | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/namespaces_test.yaml diff --git a/tests/namespaces_test.yaml b/tests/namespaces_test.yaml new file mode 100644 index 0000000..cca2132 --- /dev/null +++ b/tests/namespaces_test.yaml @@ -0,0 +1,59 @@ +suite: Test namespace with default values +templates: + - templates/core/namespaces.yaml +release: + name: release-test +tests: + - it: should output nothing by default + asserts: + - hasDocuments: + count: 0 + + - it: should output namespaces when defined as list + set: + global: + pattern: test + clusterGroup: + name: hub + namespaces: + - foo + - bar + - baz + asserts: + - isKind: + of: Namespace + - hasDocuments: + count: 3 + - documentSelector: + path: metadata.name + value: bar + equal: + path: metadata.labels["argocd.argoproj.io/managed-by"] + value: test-hub + + - it: should output namespaces when defined as map + set: + global: + pattern: test + clusterGroup: + name: hub + namespaces: + namespace1: + open-cluster-management: + labels: + openshift.io/node-selector: "" + kubernetes.io/os: linux + annotations: + openshift.io/cluster-monitoring: "true" + owner: "namespace owner" + asserts: + - isKind: + of: Namespace + - hasDocuments: + count: 2 + - documentSelector: + path: metadata.name + value: open-cluster-management + equal: + path: metadata.annotations["openshift.io/cluster-monitoring"] + value: "true"