diff --git a/templates/tests/server-test.yaml b/templates/tests/server-test.yaml index 20e2e5a5a..2ece6a40e 100644 --- a/templates/tests/server-test.yaml +++ b/templates/tests/server-test.yaml @@ -43,14 +43,14 @@ spec: fi exit 0 + {{- if .Values.server.volumeMounts }} volumeMounts: - {{- if .Values.server.volumeMounts }} - {{- toYaml .Values.server.volumeMounts | nindent 8}} - {{- end }} + {{- toYaml .Values.server.volumeMounts | nindent 8}} + {{- end }} + {{- if .Values.server.volumes }} volumes: - {{- if .Values.server.volumes }} - {{- toYaml .Values.server.volumes | nindent 4}} - {{- end }} + {{- toYaml .Values.server.volumes | nindent 4}} + {{- end }} restartPolicy: Never {{- end }} {{- end }} diff --git a/test/unit/server-test.bats b/test/unit/server-test.bats index 314703a5d..52620a9bd 100644 --- a/test/unit/server-test.bats +++ b/test/unit/server-test.bats @@ -212,11 +212,23 @@ load _helpers . | tee /dev/stderr | yq -r '.spec.volumes[] | select(.name == "plugins")' | tee /dev/stderr) - local actual=$(echo $object | + local actual=$(echo "$object" | yq -r '.emptyDir' | tee /dev/stderr) [ "${actual}" = "{}" ] } +@test "server/standalone-server-test-Pod: no server.volumes adds no volumes" { + cd `chart_dir` + + # Test that it defines it + local actual=$(helm template \ + --show-only templates/tests/server-test.yaml \ + . | tee /dev/stderr | + yq -r '.spec.volumes' | tee /dev/stderr) + + [ "${actual}" = "null" ] +} + #-------------------------------------------------------------------- # volumeMounts @@ -232,15 +244,27 @@ load _helpers . | tee /dev/stderr | yq -r '.spec.containers[0].volumeMounts[] | select(.name == "plugins")' | tee /dev/stderr) - local actual=$(echo $object | + local actual=$(echo "$object" | yq -r '.mountPath' | tee /dev/stderr) [ "${actual}" = "/usr/local/libexec/vault" ] - local actual=$(echo $object | + local actual=$(echo "$object" | yq -r '.readOnly' | tee /dev/stderr) [ "${actual}" = "true" ] } +@test "server/standalone-server-test-Pod: no server.volumeMounts adds no volumeMounts" { + cd `chart_dir` + + # Test that it defines it + local actual=$(helm template \ + --show-only templates/tests/server-test.yaml \ + . | tee /dev/stderr | + yq -r '.spec.containers[0].volumeMounts' | tee /dev/stderr) + + [ "${actual}" = "null" ] +} + #-------------------------------------------------------------------- # extraEnvironmentVars @@ -254,11 +278,11 @@ load _helpers . | tee /dev/stderr | yq -r '.spec.containers[0].env' | tee /dev/stderr) - local name=$(echo $object | + local name=$(echo "$object" | yq -r 'map(select(.name=="FOO")) | .[] .value' | tee /dev/stderr) [ "${name}" = "bar" ] - local name=$(echo $object | + local name=$(echo "$object" | yq -r 'map(select(.name=="FOOBAR")) | .[] .value' | tee /dev/stderr) [ "${name}" = "foobar" ] @@ -269,11 +293,11 @@ load _helpers . | tee /dev/stderr | yq -r '.spec.containers[0].env' | tee /dev/stderr) - local name=$(echo $object | + local name=$(echo "$object" | yq -r 'map(select(.name=="FOO")) | .[] .value' | tee /dev/stderr) [ "${name}" = "bar" ] - local name=$(echo $object | + local name=$(echo "$object" | yq -r 'map(select(.name=="FOOBAR")) | .[] .value' | tee /dev/stderr) [ "${name}" = "foobar" ] }