Skip to content

Commit 4e55656

Browse files
committed
tests: config schema validation
ensure that the validation routine points out both the problematic key/path and problematic value
1 parent 7523750 commit 4e55656

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

tests/common/lib/env.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ env.init() {
4747

4848
yq_set 'common' '.clusterAdmin.users' '["admin@example.com"]'
4949

50+
yq_set 'common' '.global.issuer' '"letsencrypt-staging"'
5051
yq_set 'common' '.issuers.letsencrypt.prod.email' '"admin@.example.com"'
5152
yq_set 'common' '.issuers.letsencrypt.staging.email' '"admin@.example.com"'
5253

tests/unit/bin/update-ips/resources/maximal-run-full-diff.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- common-config.yaml
22
+++ expected
3-
@@ -22,7 +22,7 @@
3+
@@ -23,7 +23,7 @@
44
global:
55
objectStorage:
66
ips:
@@ -12,7 +12,7 @@
1212
[ck8s] Diff found for .networkPolicies.global.objectStorage.ips in common-config.yaml (diff shows actions needed to be up to date)
1313
--- common-config.yaml
1414
+++ expected
15-
@@ -24,7 +24,7 @@
15+
@@ -25,7 +25,7 @@
1616
ips:
1717
- set-me
1818
ports:
@@ -24,7 +24,7 @@
2424
[ck8s] Diff found for .networkPolicies.global.objectStorage.ports in common-config.yaml (diff shows actions needed to be up to date)
2525
--- common-config.yaml
2626
+++ expected
27-
@@ -27,7 +27,7 @@
27+
@@ -28,7 +28,7 @@
2828
- set-me
2929
scIngress:
3030
ips:
@@ -36,7 +36,7 @@
3636
[ck8s] Diff found for .networkPolicies.global.scIngress.ips in common-config.yaml (diff shows actions needed to be up to date)
3737
--- common-config.yaml
3838
+++ expected
39-
@@ -30,7 +30,7 @@
39+
@@ -31,7 +31,7 @@
4040
- set-me
4141
wcIngress:
4242
ips:

tests/unit/validate.bats.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: validate
22
tagsFile:
33
- static
4+
- validate
45
functions:
56
setup_file: |-
67
load "../common/lib/gpg"
@@ -33,6 +34,21 @@ functions:
3334
run ck8s validate wc <<< $'y\n'
3435
assert_success
3536
37+
validate_schema: |-
38+
env.init "${@}"
39+
40+
run ck8s validate wc <<< $'y\n'
41+
assert_success
42+
43+
run yq_set 'wc' '.global.baseDomain' '"this is not a valid hostname"'
44+
run ck8s validate wc <<< $'y\n'
45+
assert_output --partial 'global.baseDomain'
46+
47+
run yq_set 'wc' '.global.baseDomain' '"this is not a valid hostname"'
48+
run ck8s validate wc <<< $'y\n'
49+
assert_output --partial '"this is not a valid hostname"'
50+
51+
3652
validate_template: |-
3753
env.init "${@}"
3854
@@ -59,6 +75,12 @@ tests:
5975
- target: prod
6076
- target: air-gapped
6177

78+
- function: validate_schema # cloud flavor
79+
tests:
80+
- target: dev
81+
- target: prod
82+
- target: air-gapped
83+
6284
- function: validate_template # cloud flavor
6385
tests:
6486
- target: dev

0 commit comments

Comments
 (0)