mirror of
https://github.com/truenas/charts.git
synced 2026-06-16 23:19:15 +08:00
portal path tests
This commit is contained in:
189
library/common-test/tests/portal/portal_path_test.yaml
Normal file
189
library/common-test/tests/portal/portal_path_test.yaml
Normal file
@@ -0,0 +1,189 @@
|
||||
suite: portal path test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should pass with default values
|
||||
documentIndex: &deploymentDoc 0
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 3
|
||||
- isKind:
|
||||
of: Deployment
|
||||
|
||||
- it: should fail with portal override with empty path
|
||||
set:
|
||||
portal:
|
||||
main:
|
||||
main:
|
||||
path:
|
||||
service:
|
||||
main:
|
||||
enabled: true
|
||||
ports:
|
||||
main:
|
||||
enabled: true
|
||||
port: 10000
|
||||
targetPort: 80
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: You have defined empty <path> in <portal>. Define a path or remove the key.
|
||||
|
||||
- it: should pass with defaults on single service/port
|
||||
documentIndex: &portalDoc 2
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
enabled: true
|
||||
ports:
|
||||
main:
|
||||
enabled: true
|
||||
port: 10000
|
||||
protocol: HTTP
|
||||
targetPort: 80
|
||||
asserts:
|
||||
- isKind:
|
||||
of: ConfigMap
|
||||
- isAPIVersion:
|
||||
of: v1
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: portal
|
||||
- isSubset:
|
||||
path: data
|
||||
content:
|
||||
path-main-main: /
|
||||
|
||||
- it: should pass with path override on single service/port
|
||||
documentIndex: *portalDoc
|
||||
set:
|
||||
portal:
|
||||
main:
|
||||
main:
|
||||
path: /some_path
|
||||
service:
|
||||
main:
|
||||
enabled: true
|
||||
ports:
|
||||
main:
|
||||
enabled: true
|
||||
port: 10000
|
||||
targetPort: 80
|
||||
asserts:
|
||||
- isKind:
|
||||
of: ConfigMap
|
||||
- isAPIVersion:
|
||||
of: v1
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: portal
|
||||
- isSubset:
|
||||
path: data
|
||||
content:
|
||||
path-main-main: /some_path
|
||||
|
||||
- it: should pass with defaults on multiple service/port
|
||||
documentIndex: &dualServicePortalDoc 3
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
enabled: true
|
||||
ports:
|
||||
main:
|
||||
enabled: true
|
||||
primary: true
|
||||
port: 10000
|
||||
protocol: HTTP
|
||||
targetPort: 80
|
||||
main2:
|
||||
enabled: true
|
||||
port: 10001
|
||||
protocol: HTTP
|
||||
targetPort: 80
|
||||
other:
|
||||
enabled: true
|
||||
ports:
|
||||
other:
|
||||
enabled: true
|
||||
primary: true
|
||||
port: 10002
|
||||
protocol: HTTP
|
||||
targetPort: 80
|
||||
other2:
|
||||
enabled: true
|
||||
port: 10003
|
||||
protocol: HTTP
|
||||
targetPort: 80
|
||||
asserts:
|
||||
- isKind:
|
||||
of: ConfigMap
|
||||
- isAPIVersion:
|
||||
of: v1
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: portal
|
||||
- isSubset:
|
||||
path: data
|
||||
content:
|
||||
path-main-main: /
|
||||
path-main-main2: /
|
||||
path-other-other: /
|
||||
path-other-other2: /
|
||||
|
||||
- it: should pass with override on multiple service/port
|
||||
documentIndex: *dualServicePortalDoc
|
||||
set:
|
||||
portal:
|
||||
main:
|
||||
main:
|
||||
path: /some_path1
|
||||
main2:
|
||||
path: /some_path2
|
||||
other:
|
||||
other:
|
||||
path: /some_path3
|
||||
other2:
|
||||
path: /some_path4
|
||||
service:
|
||||
main:
|
||||
enabled: true
|
||||
ports:
|
||||
main:
|
||||
enabled: true
|
||||
primary: true
|
||||
port: 10000
|
||||
protocol: HTTP
|
||||
targetPort: 80
|
||||
main2:
|
||||
enabled: true
|
||||
port: 10001
|
||||
protocol: HTTP
|
||||
targetPort: 80
|
||||
other:
|
||||
enabled: true
|
||||
ports:
|
||||
other:
|
||||
enabled: true
|
||||
primary: true
|
||||
port: 10002
|
||||
protocol: HTTP
|
||||
targetPort: 80
|
||||
other2:
|
||||
enabled: true
|
||||
port: 10003
|
||||
protocol: HTTP
|
||||
targetPort: 80
|
||||
asserts:
|
||||
- isKind:
|
||||
of: ConfigMap
|
||||
- isAPIVersion:
|
||||
of: v1
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: portal
|
||||
- isSubset:
|
||||
path: data
|
||||
content:
|
||||
path-main-main: /some_path1
|
||||
path-main-main2: /some_path2
|
||||
path-other-other: /some_path3
|
||||
path-other-other2: /some_path4
|
||||
@@ -15,7 +15,7 @@
|
||||
{{- if eq $portName $name -}}
|
||||
{{- if (hasKey $port "path") -}}
|
||||
{{- $portalPath = (tpl (toString $port.path) $root) -}}
|
||||
{{- if not $portalPath -}}
|
||||
{{- if or (eq $portalPath "<nil>") (not $portalPath) -}} {{/* toString on a nil key returns the string "<nil>" */}}
|
||||
{{- fail "You have defined empty <path> in <portal>. Define a path or remove the key." -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user