helm-charts/charts/library/common-test/tests/container/env_test.yaml
2023-09-13 11:24:23 +02:00

154 lines
4.1 KiB
YAML

suite: container env values
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
isNull:
path: spec.template.spec.containers[0].env
- it: KeyValue string should pass
set:
controllers.main.containers.main.env:
string: value_of_env
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: string
value: value_of_env
- it: KeyValue float should pass
set:
controllers.main.containers.main.env:
string: 4.2
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: string
value: "4.2"
- it: KeyValue int should pass
set:
controllers.main.containers.main.env:
string: 1
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: string
value: "1"
- it: List should pass
set:
controllers.main.containers.main.env:
- name: STATIC_ENV_FROM_LIST
value: STATIC_ENV_VALUE_FROM_LIST
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: STATIC_ENV_FROM_LIST
value: STATIC_ENV_VALUE_FROM_LIST
- it: Explicit ValueFrom in list should pass
set:
controllers.main.containers.main.env:
- name: DYNAMIC_ENV_FROM_LIST
valueFrom:
fieldRef:
fieldPath: spec.nodeName
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: DYNAMIC_ENV_FROM_LIST
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- it: Implicit ValueFrom should pass
set:
controllers.main.containers.main.env:
DYNAMIC_ENV:
fieldRef:
fieldPath: spec.nodeName
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: DYNAMIC_ENV
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- it: Templated value should pass
set:
controllers.main.containers.main.env:
DYNAMIC_ENV: "{{ .Release.Name }}-admin"
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: DYNAMIC_ENV
value: RELEASE-NAME-admin
- it: Combined KeyValue with Explicit ValueFrom should pass
set:
controllers.main.containers.main.env:
STATIC_ENV: static
DYNAMIC_ENV:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: DYNAMIC_ENV
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[1]
value:
name: STATIC_ENV
value: static