From 459d60b049fe776ff68e686fe1cae387c820e0fa Mon Sep 17 00:00:00 2001 From: Stavros Foteinopoulos Date: Tue, 12 Dec 2023 18:23:42 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Marco Ebert --- .../tests/controller-configmap-addheaders_test.yaml | 11 +++++++---- .../controller-configmap-proxyheaders_test.yaml | 11 +++++++---- .../tests/controller-configmap_test.yaml | 7 +++++-- .../tests/controller-daemonset_test.yaml | 4 ++-- .../tests/controller-deployment_test.yaml | 12 ++++++------ charts/ingress-nginx/tests/controller-hpa_test.yaml | 2 +- 6 files changed, 28 insertions(+), 19 deletions(-) diff --git a/charts/ingress-nginx/tests/controller-configmap-addheaders_test.yaml b/charts/ingress-nginx/tests/controller-configmap-addheaders_test.yaml index da0104450..e831d50c0 100644 --- a/charts/ingress-nginx/tests/controller-configmap-addheaders_test.yaml +++ b/charts/ingress-nginx/tests/controller-configmap-addheaders_test.yaml @@ -1,19 +1,19 @@ -suite: test controller addHeaders configmap +suite: Controller > ConfigMap > Add Headers templates: - controller-configmap-addheaders.yaml tests: - - it: should not create a configmap if addHeaders is not set + - it: should not create a ConfigMap if `controller.addHeaders` is not set set: controller.addHeaders: null asserts: - hasDocuments: count: 0 - - it: should create a configmap if addHeaders is set + - it: should create a ConfigMap if `controller.addHeaders` is set set: controller.addHeaders: - X-Another-Custom-Header: "Value" + X-Another-Custom-Header: Value asserts: - hasDocuments: count: 1 @@ -22,3 +22,6 @@ tests: - equal: path: metadata.name value: RELEASE-NAME-ingress-nginx-custom-add-headers + - equal: + path: data.X-Another-Custom-Header + value: Value diff --git a/charts/ingress-nginx/tests/controller-configmap-proxyheaders_test.yaml b/charts/ingress-nginx/tests/controller-configmap-proxyheaders_test.yaml index d59551fd3..0634a3739 100644 --- a/charts/ingress-nginx/tests/controller-configmap-proxyheaders_test.yaml +++ b/charts/ingress-nginx/tests/controller-configmap-proxyheaders_test.yaml @@ -1,19 +1,19 @@ -suite: test controller proxySetHeaders configmap +suite: Controller > ConfigMap > Proxy Headers templates: - controller-configmap-proxyheaders.yaml tests: - - it: should not create a configmap if proxySetHeaders is not set + - it: should not create a ConfigMap if `controller.proxySetHeaders` is not set set: controller.proxySetHeaders: null asserts: - hasDocuments: count: 0 - - it: should create a configmap if proxySetHeaders is set + - it: should create a ConfigMap if `controller.proxySetHeaders` is set set: controller.proxySetHeaders: - X-Custom-Header: "Value" + X-Custom-Header: Value asserts: - hasDocuments: count: 1 @@ -22,3 +22,6 @@ tests: - equal: path: metadata.name value: RELEASE-NAME-ingress-nginx-custom-proxy-headers + - equal: + path: data.X-Custom-Header + value: Value diff --git a/charts/ingress-nginx/tests/controller-configmap_test.yaml b/charts/ingress-nginx/tests/controller-configmap_test.yaml index f064c34c8..f33ae6744 100644 --- a/charts/ingress-nginx/tests/controller-configmap_test.yaml +++ b/charts/ingress-nginx/tests/controller-configmap_test.yaml @@ -1,11 +1,14 @@ -suite: test controller configmap +suite: Controller > ConfigMap templates: - controller-configmap.yaml tests: - - it: should create a configmap + - it: should create a ConfigMap asserts: - hasDocuments: count: 1 - isKind: of: ConfigMap + - equal: + path: metadata.name + value: RELEASE-NAME-ingress-nginx diff --git a/charts/ingress-nginx/tests/controller-daemonset_test.yaml b/charts/ingress-nginx/tests/controller-daemonset_test.yaml index 3eb12ddea..3089e7a1e 100644 --- a/charts/ingress-nginx/tests/controller-daemonset_test.yaml +++ b/charts/ingress-nginx/tests/controller-daemonset_test.yaml @@ -1,9 +1,9 @@ -suite: test controller daemonset +suite: Controller > DaemonSet templates: - controller-daemonset.yaml tests: - - it: should create a daemonset when controller kind is DaemonSet + - it: should create a DaemonSet when `controller.kind` is "DaemonSet" set: controller.kind: DaemonSet asserts: diff --git a/charts/ingress-nginx/tests/controller-deployment_test.yaml b/charts/ingress-nginx/tests/controller-deployment_test.yaml index 2bac5254e..da1ee1646 100644 --- a/charts/ingress-nginx/tests/controller-deployment_test.yaml +++ b/charts/ingress-nginx/tests/controller-deployment_test.yaml @@ -1,16 +1,16 @@ -suite: test controller deployment +suite: Controller > Deployment templates: - controller-deployment.yaml tests: - - it: should always create a deployment + - it: should create a Deployment asserts: - hasDocuments: count: 1 - isKind: of: Deployment - - it: custom replica count + - it: should create a Deployment with 3 replicas when `controller.replicaCount` is 3 set: controller.enabled: true controller.replicaCount: 3 @@ -19,15 +19,15 @@ tests: path: spec.replicas value: 3 - - it: custom resource limits + - it: should create a Deployment with resource limits when `controller.resources.limits` is set set: controller.enabled: true - controller.resources.limits.cpu: "500m" + controller.resources.limits.cpu: 500m controller.resources.limits.memory: "512Mi" asserts: - equal: path: spec.template.spec.containers[0].resources.limits.cpu - value: "500m" + value: 500m - equal: path: spec.template.spec.containers[0].resources.limits.memory value: "512Mi" diff --git a/charts/ingress-nginx/tests/controller-hpa_test.yaml b/charts/ingress-nginx/tests/controller-hpa_test.yaml index f62fbd901..fed1f7027 100644 --- a/charts/ingress-nginx/tests/controller-hpa_test.yaml +++ b/charts/ingress-nginx/tests/controller-hpa_test.yaml @@ -1,4 +1,4 @@ -suite: test controller hpa +suite: Controller > HPA templates: - controller-hpa.yaml