Skip to content

Commit

Permalink
Add deployment and secrets unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ppawlowski committed Feb 16, 2024
1 parent 64a76c9 commit 52c1b0a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 16 deletions.
37 changes: 37 additions & 0 deletions helm/flowforge/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: test deployment object
templates:
- deployment.yaml
set:
forge.domain: "chart-unit-tests.com"
tests:
- it: should create a deployment
asserts:
- hasDocuments:
count: 1
- isKind:
of: Deployment
- it: should create a deployment with init container
asserts:
- isNotNullOrEmpty:
path: spec.template.spec.initContainers
- lengthEqual:
path: spec.template.spec.initContainers
count: 1

- it: should create an init container with two secrets
asserts:
- isNotNullOrEmpty:
path: spec.template.spec.initContainers[0].env
- lengthEqual:
path: spec.template.spec.initContainers[0].env
count: 2
- equal:
path: spec.template.spec.initContainers[0].env[0].name
value: PGPASSWORD
- equal:
path: spec.template.spec.initContainers[0].env[1].name
value: SMTPPASSWORD
- equal:
path: spec.template.spec.initContainers[0].env[*].valueFrom.secretKeyRef.name
value: flowfuse-secrets
39 changes: 23 additions & 16 deletions helm/flowforge/tests/secrets_test.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: test secrets object
templates:
- secrets.yaml
set:
forge.domain: "chart-unit-tests.com"
tests:
- it: should create a secret object
set:
forge.domain: "chart-unit-tests.com"
forge.email.smtp:
host: smtp.gmail.com
password: ut-smtp-password
forge.email:
from: [email protected]
smtp:
host: smtp.gmail.com
password: ut-smtp-password
postgresql.auth:
username: ut-db-username
password: ut-db-password
Expand All @@ -18,11 +22,12 @@ tests:
of: Secret
- it: should create a secret object with smtp password only
set:
forge.domain: "chart-unit-tests.com"
postgresql.auth.existingSecret: "fake-existing-db-secret"
forge.email.smtp:
host: smtp.gmail.com
password: fakePassword
forge.email:
from: [email protected]
smtp:
host: smtp.gmail.com
password: fakePassword
asserts:
- hasDocuments:
count: 1
Expand All @@ -34,13 +39,14 @@ tests:
path: data.password
- it: should create a secret object with database password only
set:
forge.domain: "chart-unit-tests.com"
postgresql.auth:
username: ut-db-username
password: ut-db-password
forge.email.smtp:
host: smtp.gmail.com
existingSecret: "fake-existing-smtp-secret"
forge.email:
from: [email protected]
smtp:
host: smtp.gmail.com
existingSecret: "fake-existing-smtp-secret"
asserts:
- hasDocuments:
count: 1
Expand All @@ -54,11 +60,12 @@ tests:
path: data.smtp-password
- it: should not create the secret if both external ones are used
set:
forge.domain: "chart-unit-tests.com"
postgresql.auth.existingSecret: "fake-existing-db-secret"
forge.email.smtp:
host: smtp.gmail.com
existingSecret: "fake-existing-smtp-secret"
forge.email:
from: [email protected]
smtp:
host: smtp.gmail.com
existingSecret: "fake-existing-smtp-secret"
asserts:
- hasDocuments:
count: 0

0 comments on commit 52c1b0a

Please sign in to comment.