Skip to content

Commit

Permalink
add unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
FedericoFeresini committed Sep 15, 2023
1 parent 663a395 commit c3f14c5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
8 changes: 4 additions & 4 deletions charts/cluster-scanner/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,6 @@ spec:
- name: "{{ $key }}"
value: "{{ $value }}"
{{- end }}
{{- range $key, $value := .Values.imageSbomExtractor.env }}
- name: "{{ $key }}"
value: "{{ $value }}"
{{- end }}
{{- with .Values.runtimeStatusIntegrator }}
livenessProbe:
httpGet:
Expand Down Expand Up @@ -544,6 +540,10 @@ spec:
key: cache_redis_ttl
optional: true
{{- end }}
{{- range $key, $value := .Values.imageSbomExtractor.env }}
- name: "{{ $key }}"
value: "{{ $value }}"
{{- end }}
{{- with .Values.imageSbomExtractor }}
resources:
{{- toYaml .resources | nindent 12 }}
Expand Down
32 changes: 32 additions & 0 deletions charts/cluster-scanner/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,35 @@ tests:
content:
name: PPROF_PORT
value: "666"

- it: "sets optional envs"
templates:
- ../templates/deployment.yaml
set:
runtimeStatusIntegrator.env: { ENV_VAR_STRING: "test", ENV_VAR_NUM: 15 }
imageSbomExtractor.env: { ENV_VAR_BOOL: true }
asserts:
- not: true
isEmpty:
path: spec.template.spec.containers[0].env[?(@.name == "ENV_VAR_STRING")]
- isSubset:
path: spec.template.spec.containers[0].env[?(@.name == "ENV_VAR_STRING")]
content:
name: ENV_VAR_STRING
value: "test"
- not: true
isEmpty:
path: spec.template.spec.containers[0].env[?(@.name == "ENV_VAR_NUM")]
- isSubset:
path: spec.template.spec.containers[0].env[?(@.name == "ENV_VAR_NUM")]
content:
name: ENV_VAR_NUM
value: "15"
- not: true
isEmpty:
path: spec.template.spec.containers[1].env[?(@.name == "ENV_VAR_BOOL")]
- isSubset:
path: spec.template.spec.containers[1].env[?(@.name == "ENV_VAR_BOOL")]
content:
name: ENV_VAR_BOOL
value: "true"

0 comments on commit c3f14c5

Please sign in to comment.