From 7d03f9bb3c6eb777301cb4647dee55f069717909 Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Tue, 19 Sep 2023 10:21:36 +0200 Subject: [PATCH] chore(uplink) fix unit tests Signed-off-by: Damien Duportal --- .../templates/tests/custom_values_test.yaml | 41 ------------------- .../uplink/templates/tests/defaults_test.yaml | 25 ----------- .../templates/tests/test-connection.yaml | 15 ------- charts/uplink/tests/custom_values_test.yaml | 30 ++++++++++++++ charts/uplink/tests/defaults_test.yaml | 19 +++++++++ 5 files changed, 49 insertions(+), 81 deletions(-) delete mode 100644 charts/uplink/templates/tests/custom_values_test.yaml delete mode 100644 charts/uplink/templates/tests/defaults_test.yaml delete mode 100644 charts/uplink/templates/tests/test-connection.yaml create mode 100644 charts/uplink/tests/custom_values_test.yaml create mode 100644 charts/uplink/tests/defaults_test.yaml diff --git a/charts/uplink/templates/tests/custom_values_test.yaml b/charts/uplink/templates/tests/custom_values_test.yaml deleted file mode 100644 index d32e8e665..000000000 --- a/charts/uplink/templates/tests/custom_values_test.yaml +++ /dev/null @@ -1,41 +0,0 @@ -suite: test secret.yaml -templates: - - secret.yaml -tests: - - it: should ensure the secret has correct metadata - set: - postgresql.url: "example-url" - client.id: "example-id" - client.secret: "example-secret" - sentry.dsn: "example-dsn" - asserts: - - isKind: - of: Secret - - matchRegex: - path: metadata.name - pattern: "^uplink.*" # General check to ensure name starts with "uplink" - - equal: - path: metadata.name - value: "RELEASE-NAME-uplink." # Specific check for the exact name - - - it: should check data fields in secret - set: - postgresql.url: "example-url" - client.id: "example-id" - client.secret: "example-secret" - sentry.dsn: "example-dsn" - asserts: - - equal: - path: data.postgresql.url - value: "ZXhhbXBsZS11cmw=" # Base64 encoded value of "example-url" - - equal: - path: data.client.id - value: "ZXhhbXBsZS1pZA==" # Base64 encoded value of "example-id" - - equal: - path: data.client.secret - value: "ZXhhbXBsZS1zZWNyZXQ=" # Base64 encoded value of "example-secret" - - equal: - path: data.sentry.dsn - value: "ZXhhbXBsZS1kc24=" # Base64 encoded value of "example-dsn" - - # Add more tests as required... diff --git a/charts/uplink/templates/tests/defaults_test.yaml b/charts/uplink/templates/tests/defaults_test.yaml deleted file mode 100644 index e6e5b8583..000000000 --- a/charts/uplink/templates/tests/defaults_test.yaml +++ /dev/null @@ -1,25 +0,0 @@ -suite: test default behavior of secret.yaml with default values -templates: - - secret.yaml -tests: - - it: should render with default values without error - asserts: - - isKind: - of: Secret - - matchRegex: - path: metadata.name - pattern: "^uplink.*" # Assuming the default behavior still starts with "uplink" - - notMatchRegex: - path: data.postgresql.url - pattern: "." # Assuming no default value provided - - notMatchRegex: - path: data.client.id - pattern: "." # Assuming no default value provided - - notMatchRegex: - path: data.client.secret - pattern: "." # Assuming no default value provided - - notMatchRegex: - path: data.sentry.dsn - pattern: "." # Assuming no default value provided - - # Add more tests as required to check default behavior... diff --git a/charts/uplink/templates/tests/test-connection.yaml b/charts/uplink/templates/tests/test-connection.yaml deleted file mode 100644 index ada6a5202..000000000 --- a/charts/uplink/templates/tests/test-connection.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "uplink.fullname" . }}-test-connection" - labels: -{{ include "uplink.labels" . | indent 4 }} - annotations: - "helm.sh/hook": test-success -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "uplink.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/charts/uplink/tests/custom_values_test.yaml b/charts/uplink/tests/custom_values_test.yaml new file mode 100644 index 000000000..e2382df02 --- /dev/null +++ b/charts/uplink/tests/custom_values_test.yaml @@ -0,0 +1,30 @@ +suite: test secret.yaml +templates: + - secret.yaml +set: + postgresql: + url: "example-url" + client: + id: "example-id" + secret: "example-secret" + sentry.dsn: "example-dsn" +tests: + - it: should ensure the secret is created with custom credentials + asserts: + - isKind: + of: Secret + - equal: + path: metadata.name + value: RELEASE-NAME-uplink + - equal: + path: data['postgresql.url'] + value: "ZXhhbXBsZS11cmw=" # Base64 encoded value of "example-url" + - equal: + path: data['client.id'] + value: "ZXhhbXBsZS1pZA==" # Base64 encoded value of "example-id" + - equal: + path: data['client.secret'] + value: "ZXhhbXBsZS1zZWNyZXQ=" # Base64 encoded value of "example-secret" + - equal: + path: data['sentry.dsn'] + value: "ZXhhbXBsZS1kc24=" # Base64 encoded value of "example-dsn" diff --git a/charts/uplink/tests/defaults_test.yaml b/charts/uplink/tests/defaults_test.yaml new file mode 100644 index 000000000..55b8952e5 --- /dev/null +++ b/charts/uplink/tests/defaults_test.yaml @@ -0,0 +1,19 @@ +suite: test default behavior of secret.yaml with default values +templates: + - secret.yaml +tests: + - it: should render with default values without error + asserts: + - isKind: + of: Secret + - equal: + path: metadata.name + value: RELEASE-NAME-uplink + - notExists: + path: data.postgresql.url + - notExists: + path: data.client.id + - notExists: + path: data.client.secret + - notExists: + path: data.sentry.dsn