make sure data is correct

This commit is contained in:
Stavros kois
2024-03-10 01:14:56 +02:00
parent 7caf9f13d3
commit dee265a46a
2 changed files with 34 additions and 3 deletions

View File

@@ -168,6 +168,32 @@ tests:
- failedTemplate:
errorMessage: CNPG Recovery - Expected [recovery.revision] to be a string, got [float64]
- it: should fail with pgVersion not a string
set:
cnpg:
my-pg:
enabled: true
user: test-user
database: test-db
mode: standalone
pgVersion: 5
asserts:
- failedTemplate:
errorMessage: CNPG - Expected [pgVersion] to be a string, but got [float64]
- it: should fail with invalid pgVersion
set:
cnpg:
my-pg:
enabled: true
user: test-user
database: test-db
mode: standalone
pgVersion: invalid
asserts:
- failedTemplate:
errorMessage: CNPG - Expected [pgVersion] to be one of [15, 16], but got [invalid]
- it: should fail with invalid recovery method
set:
cnpg:

View File

@@ -8,10 +8,15 @@
{{- end -}}
{{- end -}}
{{- if (hasKey $objectData "version") -}}
{{- if $objectData.version -}}
{{- if not (kindIs "string" $objectData.pgVersion) -}}
{{/* We must ensure that this is a string, as it is used in image selector that require a string */}}
{{- fail (printf "CNPG - Expected [pgVersion] to be a string, but got [%s]" (kindOf $objectData.pgVersion)) -}}
{{- end -}}
{{- $validVersions := (list "15" "16") -}}
{{- if not (mustHas ( toString $objectData.version ) $validVersions) -}}
{{- fail (printf "CNPG - Expected [version] to be one of [%s], but got [%s]" (join ", " $validVersions) $objectData.version) -}}
{{- if not (mustHas $objectData.pgVersion $validVersions) -}}
{{- fail (printf "CNPG - Expected [pgVersion] to be one of [%s], but got [%s]" (join ", " $validVersions) $objectData.pgVersion) -}}
{{- end -}}
{{- end -}}