Files
Kjeld Schouten 681160d53b feat(common): add additional tests for default storage class (#770)
**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->
⚒️ Fixes  # <!--(issue)-->

**⚙️ Type of change**

- [ ] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [ ] ⚖️ My code follows the style guidelines of this project
- [ ] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [ ] ⬆️ I increased versions for any altered app according to semantic
versioning
- [ ] I made sure the title starts with `feat(chart-name):`,
`fix(chart-name):` or `chore(chart-name):`

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._

---------

Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
2024-04-07 18:34:51 +03:00

193 lines
5.1 KiB
YAML

suite: storageClass spec test
templates:
- common.yaml
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should generate correct spec with provisioner provided
set:
storageClass:
example1:
enabled: true
provisioner: some.provisioner.io
asserts:
- documentIndex: &storageClassDoc 0
isKind:
of: StorageClass
- documentIndex: *storageClassDoc
isAPIVersion:
of: storage.k8s.io/v1
- documentIndex: *storageClassDoc
equal:
path: provisioner
value: some.provisioner.io
- documentIndex: *storageClassDoc
equal:
path: reclaimPolicy
value: Retain
- documentIndex: *storageClassDoc
equal:
path: allowVolumeExpansion
value: true
- documentIndex: *storageClassDoc
equal:
path: volumeBindingMode
value: Immediate
- documentIndex: *storageClassDoc
equal:
path: metadata.annotations
value:
storageclass.kubernetes.io/is-default-class: "false"
- it: should generate correct spec with non-default reclaim policy
set:
storageClass:
example1:
enabled: true
provisioner: some.provisioner.io
reclaimPolicy: Delete
asserts:
- documentIndex: &storageClassDoc 0
isKind:
of: StorageClass
- documentIndex: *storageClassDoc
equal:
path: reclaimPolicy
value: Delete
- it: should generate correct spec with non-default allowVolumeExpansion
set:
storageClass:
example1:
enabled: true
provisioner: some.provisioner.io
allowVolumeExpansion: false
asserts:
- documentIndex: &storageClassDoc 0
isKind:
of: StorageClass
- documentIndex: *storageClassDoc
equal:
path: allowVolumeExpansion
value: false
- it: should generate correct spec with parameters provided from tpl
set:
test:
key1: value1
key2: value2
storageClass:
example1:
enabled: true
provisioner: some.provisioner.io
parameters:
param1: "{{ .Values.test.key1 }}"
param2: "{{ .Values.test.key2 }}"
asserts:
- documentIndex: &storageClassDoc 0
isKind:
of: StorageClass
- documentIndex: *storageClassDoc
equal:
path: parameters
value:
param1: value1
param2: value2
- it: should generate correct spec with parameters provided
set:
storageClass:
example1:
enabled: true
provisioner: some.provisioner.io
parameters:
param1: value1
param2: value2
asserts:
- documentIndex: &storageClassDoc 0
isKind:
of: StorageClass
- documentIndex: *storageClassDoc
equal:
path: parameters
value:
param1: value1
param2: value2
- it: should generate correct spec with mountOptions provided
set:
storageClass:
example1:
enabled: true
provisioner: some.provisioner.io
mountOptions:
- option1
- option2=value2
asserts:
- documentIndex: &storageClassDoc 0
isKind:
of: StorageClass
- documentIndex: *storageClassDoc
equal:
path: mountOptions
value:
- option1
- option2=value2
- it: should generate correct spec with mountOptions provided from tpl
set:
test:
key1: option1
key2: value2
storageClass:
example1:
enabled: true
provisioner: some.provisioner.io
mountOptions:
- "{{ .Values.test.key1 }}"
- option2={{ .Values.test.key2 }}
asserts:
- documentIndex: &storageClassDoc 0
isKind:
of: StorageClass
- documentIndex: *storageClassDoc
equal:
path: mountOptions
value:
- option1
- option2=value2
# Failures
- it: should fail without provisioner
set:
storageClass:
example1:
enabled: true
provisioner: ""
asserts:
- failedTemplate:
errorMessage: Storage Class - Expected non-empty [provisioner]
- it: should fail with invalid reclaimPolicy
set:
storageClass:
example1:
enabled: true
provisioner: some.provisioner.io
reclaimPolicy: invalid
asserts:
- failedTemplate:
errorMessage: Storage Class - Expected [reclaimPolicy] to be one of [Retain, Delete], but got [invalid]
- it: should fail with invalid volumeBindingMode
set:
storageClass:
example1:
enabled: true
provisioner: some.provisioner.io
volumeBindingMode: invalid
asserts:
- failedTemplate:
errorMessage: Storage Class - Expected [volumeBindingMode] to be one of [WaitForFirstConsumer, Immediate], but got [invalid]