Skip to content

Commit

Permalink
Add some unit tests. (#610)
Browse files Browse the repository at this point in the history
* Add some unit tests.

These are more succinct and much faster than the terratest tests.
  • Loading branch information
robholland authored Nov 21, 2024
1 parent a33b8c1 commit 4d90e8a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,11 @@ jobs:

- name: Run template tests
working-directory: charts/temporal/tests
run: go test
run: go test

- name: Install helm-unittest
run: helm plugin install https://github.com/helm-unittest/helm-unittest.git

- name: Run helm-unittest
working-directory: charts/temporal
run: helm unittest .
1 change: 1 addition & 0 deletions charts/temporal/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
.idea/
*.tmproj
.vscode/
tests/
54 changes: 54 additions & 0 deletions charts/temporal/tests/server_deployment_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
suite: test server deployment
templates:
- server-deployment.yaml
- server-configmap.yaml
set:
server:
replicaCount: 2
resources:
requests:
cpu: 100m
frontend:
replicaCount: 3
resources:
requests:
cpu: 200m
tests:
- it: defaults to service wide replica count
template: templates/server-deployment.yaml
documentSelector:
path: '$[?(@.metadata.name != "RELEASE-NAME-temporal-frontend")].kind'
value: Deployment
matchMany: true
asserts:
- equal:
path: spec.replicas
value: 2
- it: favours service specific replica count
template: templates/server-deployment.yaml
documentSelector:
path: metadata.name
value: RELEASE-NAME-temporal-frontend
asserts:
- equal:
path: spec.replicas
value: 3
- it: defaults to service wide resources
template: templates/server-deployment.yaml
documentSelector:
path: '$[?(@.metadata.name != "RELEASE-NAME-temporal-frontend")].kind'
value: Deployment
matchMany: true
asserts:
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: 100m
- it: favours service specific resources
template: templates/server-deployment.yaml
documentSelector:
path: metadata.name
value: RELEASE-NAME-temporal-frontend
asserts:
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: 200m

0 comments on commit 4d90e8a

Please sign in to comment.