Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
georgekaz committed May 28, 2020
1 parent d06d640 commit b900fa7
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ load _helpers
#--------------------------------------------------------------------
# extraVolumes

@test "server/standalone-StatefulSet: adds extra volume" {
@test "server/standalone-StatefulSet: server.extraVolumes adds extra volume" {
cd `chart_dir`

# Test that it defines it
Expand Down Expand Up @@ -293,7 +293,7 @@ load _helpers
[ "${actual}" = "/vault/userconfig/foo" ]
}

@test "server/standalone-StatefulSet: adds extra secret volume" {
@test "server/standalone-StatefulSet: server.extraVolumes adds extra secret volume" {
cd `chart_dir`

# Test that it defines it
Expand Down Expand Up @@ -370,6 +370,47 @@ load _helpers
yq -r '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "audit")' | tee /dev/stderr)
}

#--------------------------------------------------------------------
# volumes

@test "server/standalone-StatefulSet: server.volumes adds volume" {
cd `chart_dir`

# Test that it defines it
local object=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.volumes[0].name=plugins' \
--set 'server.volumes[0].emptyDir=\{\}' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.volumes[] | select(.name == "plugins")' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.emptyDir' | tee /dev/stderr)
[ "${actual}" = "{}" ]

#--------------------------------------------------------------------
# volumeMounts

@test "server/standalone-StatefulSet: server.volumeMounts adds volumeMount" {
cd `chart_dir`

# Test that it defines it
local object=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.volumeMounts[0].name=plugins' \
--set 'server.volumeMounts[0].mountPath=/usr/local/libexec/vault' \
--set 'server.volumeMounts[0].readOnly=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "plugins")' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.mountPath' | tee /dev/stderr)
[ "${actual}" = "/usr/local/libexec/vault" ]

local actual=$(echo $object |
yq -r '.readOnly' | tee /dev/stderr)
[ "${actual}" = "true" ]

#--------------------------------------------------------------------
# extraEnvironmentVars

Expand Down

0 comments on commit b900fa7

Please sign in to comment.