Files
jellyfin-helm/charts/jellyfin/tests/envfrom_test.yaml
T
Aleksei SviridkinandClaude a08951aaa3 test(charts): comprehensive test improvements and expansions
Phase 1: Improve and expand existing test coverage with edge cases,
validations, and regression tests.

Changes:
- Rename cache_persistence_test → persistence_test with full coverage
  for config, media, and cache persistence (60+ tests)
- Rename service_ipv6_test → service_test with full service coverage
  including types, ports, annotations, LoadBalancer settings (80+ tests)
- Rename startup_probe_test → probes_test covering all three probe types:
  startup, liveness, readiness with all configurations (60+ tests)
- Expand networkpolicy_test with IPv4/IPv6 CIDR validations, egress
  restrictions, and edge cases (+13 tests)
- Expand init_containers_test with full container spec and merge order
  validation (+5 tests)
- Expand envfrom_test with prefix, optional, and multiple source
  combinations (+9 tests)

Test coverage improvements:
- All edge cases for persistence types (pvc, hostPath, emptyDir)
- Service type validation (ClusterIP, NodePort, LoadBalancer, ExternalName)
- Probe types validation (httpGet, tcpSocket, exec)
- NetworkPolicy CIDR format validation (IPv4/IPv6)
- Comprehensive regression tests for default behavior

Total: 6 improved test files, 230+ new test cases

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2025-11-08 17:23:18 +03:00

271 lines
7.7 KiB
YAML

suite: test envFrom
templates:
- deployment.yaml
tests:
- it: should not have envFrom by default
asserts:
- isNull:
path: spec.template.spec.containers[0].envFrom
- it: should add envFrom from ConfigMap
set:
jellyfin.envFrom:
- configMapRef:
name: jellyfin-config
asserts:
- isNotNull:
path: spec.template.spec.containers[0].envFrom
- lengthEqual:
path: spec.template.spec.containers[0].envFrom
count: 1
- equal:
path: spec.template.spec.containers[0].envFrom[0].configMapRef.name
value: jellyfin-config
- it: should add envFrom from Secret
set:
jellyfin.envFrom:
- secretRef:
name: jellyfin-secrets
asserts:
- equal:
path: spec.template.spec.containers[0].envFrom[0].secretRef.name
value: jellyfin-secrets
- it: should support multiple envFrom sources
set:
jellyfin.envFrom:
- configMapRef:
name: jellyfin-config
- secretRef:
name: jellyfin-secrets
- configMapRef:
name: jellyfin-extra-config
asserts:
- lengthEqual:
path: spec.template.spec.containers[0].envFrom
count: 3
- equal:
path: spec.template.spec.containers[0].envFrom[0].configMapRef.name
value: jellyfin-config
- equal:
path: spec.template.spec.containers[0].envFrom[1].secretRef.name
value: jellyfin-secrets
- equal:
path: spec.template.spec.containers[0].envFrom[2].configMapRef.name
value: jellyfin-extra-config
- it: should support optional ConfigMap
set:
jellyfin.envFrom:
- configMapRef:
name: optional-config
optional: true
asserts:
- equal:
path: spec.template.spec.containers[0].envFrom[0].configMapRef.optional
value: true
- it: should support optional Secret
set:
jellyfin.envFrom:
- secretRef:
name: optional-secret
optional: true
asserts:
- equal:
path: spec.template.spec.containers[0].envFrom[0].secretRef.optional
value: true
- it: should support prefix for ConfigMap
set:
jellyfin.envFrom:
- configMapRef:
name: my-config
prefix: CONFIG_
asserts:
- equal:
path: spec.template.spec.containers[0].envFrom[0].prefix
value: CONFIG_
- it: should support prefix for Secret
set:
jellyfin.envFrom:
- secretRef:
name: my-secret
prefix: SECRET_
asserts:
- equal:
path: spec.template.spec.containers[0].envFrom[0].prefix
value: SECRET_
- it: should work alongside regular env variables
set:
jellyfin.env:
- name: CUSTOM_VAR
value: custom-value
jellyfin.envFrom:
- configMapRef:
name: jellyfin-config
asserts:
- isNotNull:
path: spec.template.spec.containers[0].env
- isNotNull:
path: spec.template.spec.containers[0].envFrom
- contains:
path: spec.template.spec.containers[0].env
content:
name: CUSTOM_VAR
value: custom-value
- equal:
path: spec.template.spec.containers[0].envFrom[0].configMapRef.name
value: jellyfin-config
# =============================================================================
# EDGE CASES AND ADDITIONAL VALIDATIONS
# =============================================================================
- it: should handle empty envFrom array
set:
jellyfin.envFrom: []
asserts:
- isNull:
path: spec.template.spec.containers[0].envFrom
- it: should support both configMapRef and secretRef with optional and prefix
set:
jellyfin.envFrom:
- configMapRef:
name: my-config
optional: true
prefix: CFG_
- secretRef:
name: my-secret
optional: false
prefix: SEC_
asserts:
- lengthEqual:
path: spec.template.spec.containers[0].envFrom
count: 2
- equal:
path: spec.template.spec.containers[0].envFrom[0].configMapRef.name
value: my-config
- equal:
path: spec.template.spec.containers[0].envFrom[0].configMapRef.optional
value: true
- equal:
path: spec.template.spec.containers[0].envFrom[0].prefix
value: CFG_
- equal:
path: spec.template.spec.containers[0].envFrom[1].secretRef.name
value: my-secret
- equal:
path: spec.template.spec.containers[0].envFrom[1].secretRef.optional
value: false
- equal:
path: spec.template.spec.containers[0].envFrom[1].prefix
value: SEC_
- it: should support multiple ConfigMaps with different prefixes
set:
jellyfin.envFrom:
- configMapRef:
name: config-1
prefix: APP1_
- configMapRef:
name: config-2
prefix: APP2_
- configMapRef:
name: config-3
prefix: APP3_
asserts:
- lengthEqual:
path: spec.template.spec.containers[0].envFrom
count: 3
- equal:
path: spec.template.spec.containers[0].envFrom[0].prefix
value: APP1_
- equal:
path: spec.template.spec.containers[0].envFrom[1].prefix
value: APP2_
- equal:
path: spec.template.spec.containers[0].envFrom[2].prefix
value: APP3_
- it: should support multiple Secrets with different prefixes
set:
jellyfin.envFrom:
- secretRef:
name: secret-1
prefix: DB_
- secretRef:
name: secret-2
prefix: API_
asserts:
- lengthEqual:
path: spec.template.spec.containers[0].envFrom
count: 2
- equal:
path: spec.template.spec.containers[0].envFrom[0].prefix
value: DB_
- equal:
path: spec.template.spec.containers[0].envFrom[1].prefix
value: API_
- it: should not have prefix when not specified
set:
jellyfin.envFrom:
- configMapRef:
name: no-prefix-config
asserts:
- isNull:
path: spec.template.spec.containers[0].envFrom[0].prefix
- it: should not have optional field when not specified
set:
jellyfin.envFrom:
- configMapRef:
name: required-config
asserts:
- isNull:
path: spec.template.spec.containers[0].envFrom[0].configMapRef.optional
# Regression: verify envFrom doesn't interfere with other env settings
- it: should preserve JELLYFIN_PublishedServerUrl when envFrom is used
set:
jellyfin.env:
- name: JELLYFIN_PublishedServerUrl
value: https://jellyfin.example.com
jellyfin.envFrom:
- configMapRef:
name: extra-config
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: JELLYFIN_PublishedServerUrl
value: https://jellyfin.example.com
# Complex scenario with many sources
- it: should support large number of envFrom sources
set:
jellyfin.envFrom:
- configMapRef:
name: config-1
- secretRef:
name: secret-1
- configMapRef:
name: config-2
prefix: PREFIX_
- secretRef:
name: secret-2
optional: true
- configMapRef:
name: config-3
optional: true
prefix: OPT_
asserts:
- lengthEqual:
path: spec.template.spec.containers[0].envFrom
count: 5