helm-charts/charts/library/common-test/tests/configmap/metadata_test.yaml
Bernd Schorgers 8b33237e27
feat(common): Release library 3.7.0 (#377)
Signed-off-by: solidDoWant <fred.heinecke@yahoo.com>
Co-authored-by: Patrick Collins <Patricol@users.noreply.github.com>
Co-authored-by: Patrick Collins <patrick.collins@gainbridge.io>
Co-authored-by: Lawrence Gil <larrywtf609@gmail.com>
Co-authored-by: solidDoWant <fred.heinecke@yahoo.com>
2025-02-07 20:03:04 +01:00

238 lines
7 KiB
YAML

---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: configmap metadata
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default metadata should pass
set:
configMaps:
config:
data:
test: test
asserts:
- hasDocuments:
count: 2
- documentIndex: &ConfigmapDocument 0
isKind:
of: ConfigMap
- documentIndex: *ConfigmapDocument
notExists:
path: metadata.annotations
- documentIndex: *ConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
- it: custom metadata should pass
set:
configMaps:
config:
data:
test: test
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- hasDocuments:
count: 2
- documentIndex: &ConfigmapDocument 0
isKind:
of: ConfigMap
- documentIndex: *ConfigmapDocument
equal:
path: metadata.annotations
value:
test_annotation: test
- documentIndex: *ConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
test_label: test
- it: custom metadata with global metadata should pass
set:
global:
labels:
global_label: test
annotations:
global_annotation: test
configMaps:
config:
data:
test: test
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- hasDocuments:
count: 2
- documentIndex: &ConfigmapDocument 0
isKind:
of: ConfigMap
- documentIndex: *ConfigmapDocument
equal:
path: metadata.annotations
value:
global_annotation: test
test_annotation: test
- documentIndex: *ConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
global_label: test
helm.sh/chart: common-test-1.0.0
test_label: test
- it: default configuration from folder with binary files should fail
set:
configMaps:
config:
data:
test: test
configMapsFromFolder:
enabled: true
basePath: ci/configMapsFolder
asserts:
- failedTemplate:
errorMessage: "There was an error loading ConfigMap: test_2. If it was automatically generated from a folder verify that files are properly flagged as `binary` or `escaped`"
- it: default metadata from folder should pass
set:
configMaps:
config:
data:
test: test
configMapsFromFolder:
enabled: true
basePath: ci/configMapsFolder
configMapsOverrides:
test_2:
fileAttributeOverrides:
helm.jpg:
binary: true
test_2.yaml:
escaped: true
asserts:
- hasDocuments:
count: 4
- documentIndex: &FirstConfigmapDocument 0
isKind:
of: ConfigMap
- documentIndex: *FirstConfigmapDocument
notExists:
path: metadata.annotations
- documentIndex: *FirstConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
- documentIndex: &SecondConfigmapDocument 1
isKind:
of: ConfigMap
- documentIndex: *SecondConfigmapDocument
notExists:
path: metadata.annotations
- documentIndex: *SecondConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
- documentIndex: &ThirdConfigmapDocument 2
isKind:
of: ConfigMap
- documentIndex: *ThirdConfigmapDocument
notExists:
path: metadata.annotations
- documentIndex: *ThirdConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
- it: custom metadata from folder should pass
set:
configMaps:
config:
data:
test: test
configMapsFromFolder:
enabled: true
basePath: ci/configMapsFolder
configMapsOverrides:
test_2:
labels:
test: test_label
annotations:
test: test_annotation
fileAttributeOverrides:
helm.jpg:
binary: true
test_2.yaml:
escaped: true
asserts:
- hasDocuments:
count: 4
- documentIndex: &FirstConfigmapDocument 0
isKind:
of: ConfigMap
- documentIndex: *FirstConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
- documentIndex: &SecondConfigmapDocument 1
isKind:
of: ConfigMap
- documentIndex: *SecondConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
- documentIndex: &ThirdConfigmapDocument 2
isKind:
of: ConfigMap
- documentIndex: *ThirdConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
test: test_label
- documentIndex: *ThirdConfigmapDocument
equal:
path: metadata.annotations
value:
test: test_annotation