Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
Fix tests to check for null and default, resolve indent of template
Browse files Browse the repository at this point in the history
  • Loading branch information
s3than committed Nov 8, 2018
1 parent 8739b70 commit 4124373
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion templates/server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
spec:
{{- if .Values.server.affinity }}
affinity:
{{ tpl .Values.server.affinity . }}
{{ tpl .Values.server.affinity . | nindent 8 | trim }}
{{- end }}
terminationGracePeriodSeconds: 10
securityContext:
Expand Down
43 changes: 22 additions & 21 deletions test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,6 @@ load _helpers
[ "${actual}" = "true" ]
}


@test "server/StatefulSet: affinity not set with server.affinity" {
cd `chart_dir`
local actual=$(helm template \
-x templates/server-statefulset.yaml \
--set 'server.affinity=' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "server/StatefulSet: affinity set with server.affinity as empty" {
cd `chart_dir`
local actual=$(helm template \
-x templates/server-statefulset.yaml \
--set 'server.affinity=""' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "server/StatefulSet: enable with global.enabled false" {
cd `chart_dir`
local actual=$(helm template \
Expand Down Expand Up @@ -113,6 +92,28 @@ load _helpers
[ "${actual}" = "2" ]
}

#--------------------------------------------------------------------
# affinity

@test "server/StatefulSet: affinity not set with server.affinity" {
cd `chart_dir`
local actual=$(helm template \
-x templates/server-statefulset.yaml \
--set 'server.affinity=null' \
. | tee /dev/stderr |
yq '.spec.template.spec | .affinity? == null' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "server/StatefulSet: affinity set by default" {
cd `chart_dir`
local actual=$(helm template \
-x templates/server-statefulset.yaml \
. | tee /dev/stderr |
yq '.spec.template.spec.affinity | .podAntiAffinity? != null' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

#--------------------------------------------------------------------
# extraVolumes

Expand Down

0 comments on commit 4124373

Please sign in to comment.