Files
library-charts/library/common-test/tests/storageClass/metadata_test.yaml
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

102 lines
3.1 KiB
YAML

suite: storageClass metadata test
templates:
- common.yaml
chart:
appVersion: &appVer v9.9.9
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should pass with storageClass created with labels and annotations
set:
label1: label1
label2: global_label2
annotation1: annotation1
annotation2: global_annotation2
global:
labels:
g_label1: global_label1
g_label2: "{{ .Values.label2 }}"
annotations:
g_annotation1: global_annotation1
g_annotation2: "{{ .Values.annotation2 }}"
storageClass:
example1:
enabled: true
provisioner: some.provisioner.io
labels:
label1: "{{ .Values.label1 }}"
label2: label2
annotations:
annotation1: "{{ .Values.annotation1 }}"
annotation2: annotation2
annotationsList:
- name: some-annotation
value: some-value
labelsList:
- name: some-label
value: some-value
asserts:
- documentIndex: &storageClassDoc 0
isKind:
of: StorageClass
- documentIndex: *storageClassDoc
isAPIVersion:
of: storage.k8s.io/v1
- documentIndex: *storageClassDoc
equal:
path: metadata.annotations
value:
annotation1: annotation1
annotation2: annotation2
g_annotation1: global_annotation1
g_annotation2: global_annotation2
some-annotation: some-value
storageclass.kubernetes.io/is-default-class: "false"
- documentIndex: *storageClassDoc
equal:
path: metadata.labels
value:
app: common-test-1.0.0
release: test-release-name
helm-revision: "0"
helm.sh/chart: common-test-1.0.0
app.kubernetes.io/name: common-test
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: *appVer
g_label1: global_label1
g_label2: global_label2
label1: label1
label2: label2
some-label: some-value
- it: should pass with storageClass default set to true
set:
storageClass:
example1:
enabled: true
provisioner: some.provisioner.io
isDefault: true
asserts:
- documentIndex: &storageClassDoc 0
isKind:
of: StorageClass
- documentIndex: *storageClassDoc
isAPIVersion:
of: storage.k8s.io/v1
- documentIndex: *storageClassDoc
equal:
path: metadata.annotations
value:
storageclass.kubernetes.io/is-default-class: "true"
- it: should fail with isDefault not a boolean
set:
storageClass:
example1:
enabled: true
provisioner: some.provisioner.io
isDefault: invalid
asserts:
- failedTemplate:
errorMessage: Storage Class - Expected [isDefault] to be [boolean], but got [string]