Skip to content

Commit

Permalink
feat(test/unit/csi-daemonset.bats): add tests as suggested by @benashz
Browse files Browse the repository at this point in the history
Signed-off-by: Toni Tauro <[email protected]>
  • Loading branch information
eyenx committed Sep 15, 2021
1 parent b52d1f6 commit b2af383
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions test/unit/csi-daemonset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,68 @@ load _helpers
[ "${actual}" = "{}" ]
}

@test "csi/daemonset: csi providersDir default" {
cd `chart_dir`

# Test that it defines it
local object=$(helm template \
--show-only templates/csi-daemonset.yaml \
--set 'csi.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.volumes[] | select(.name == "providervol")' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.hostPath.path' | tee /dev/stderr)
[ "${actual}" = "/etc/kubernetes/secrets-store-csi-providers" ]
}

@test "csi/daemonset: csi kubeletRootDir default" {
cd `chart_dir`

# Test that it defines it
local object=$(helm template \
--show-only templates/csi-daemonset.yaml \
--set 'csi.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.volumes[] | select(.name == "mountpoint-dir")' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.hostPath.path' | tee /dev/stderr)
[ "${actual}" = "/var/lib/kubelet/pods" ]
}

@test "csi/daemonset: csi providersDir override " {
cd `chart_dir`

# Test that it defines it
local object=$(helm template \
--show-only templates/csi-daemonset.yaml \
--set 'csi.enabled=true' \
--set 'csi.daemonSet.providersDir=/alt/csi-prov-dir' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.volumes[] | select(.name == "providervol")' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.hostPath.path' | tee /dev/stderr)
[ "${actual}" = "/alt/csi-prov-dir" ]
}

@test "csi/daemonset: csi kubeletRootDir override" {
cd `chart_dir`

# Test that it defines it
local object=$(helm template \
--show-only templates/csi-daemonset.yaml \
--set 'csi.enabled=true' \
--set 'csi.daemonSet.kubeletRootDir=/alt/kubelet-root' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.volumes[] | select(.name == "mountpoint-dir")' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.hostPath.path' | tee /dev/stderr)
[ "${actual}" = "/alt/kubelet-root/pods" ]
}

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

Expand Down

0 comments on commit b2af383

Please sign in to comment.