prometheus-postgres-exporter/unittests/secrets/database.yaml
2024-11-25 11:53:09 +01:00

104 lines
3.2 KiB
YAML

chart:
appVersion: 0.1.0
version: 0.1.0
suite: Secret database template (basic)
release:
name: prometheus-postgres-exporter-unittest
namespace: testing
templates:
- templates/prometheus-postgres-exporter/secretDatabase.yaml
tests:
- it: Skip rendering by using existing secret.
set:
config.database.existingSecret.enabled: true
asserts:
- hasDocuments:
count: 0
- it: Expect error when no variable is defined.
asserts:
- failedTemplate:
errorMessage: No `databaseConnectionUrl` defined!
- it: Expect error when variable `databaseUsername` is not defined.
set:
# config.database.secret.databaseUsername: ""
config.database.secret.databasePassword: "postgres"
config.database.secret.databaseConnectionUrl: "localhost:5432/postgres?sslmode=disable"
asserts:
- failedTemplate:
errorMessage: No `databaseUsername` defined!
- it: Expect error when variable `databasePassword` is not defined.
set:
config.database.secret.databaseUsername: "postgres"
# config.database.secret.databasePassword: "postgres"
config.database.secret.databaseConnectionUrl: "localhost:5432/postgres?sslmode=disable"
asserts:
- failedTemplate:
errorMessage: No `databasePassword` defined!
- it: Expect error when variable `databaseConnectionUrl` is not defined.
set:
config.database.secret.databaseUsername: "postgres"
config.database.secret.databasePassword: "postgres"
# config.database.secret.databaseConnectionUrl: "localhost:5432/postgres?sslmode=disable"
asserts:
- failedTemplate:
errorMessage: No `databaseConnectionUrl` defined!
- it: Rendering database secret.
set:
config.database.secret.databaseUsername: "postgres"
config.database.secret.databasePassword: "postgres"
config.database.secret.databaseConnectionUrl: "localhost:5432/postgres?sslmode=disable"
asserts:
- hasDocuments:
count: 1
- containsDocument:
apiVersion: v1
kind: Secret
name: prometheus-postgres-exporter-unittest-database-env
namespace: testing
- notExists:
path: metadata.annotations
- equal:
path: metadata.labels
value:
app.kubernetes.io/instance: prometheus-postgres-exporter-unittest
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: prometheus-postgres-exporter
app.kubernetes.io/version: 0.1.0
helm.sh/chart: prometheus-postgres-exporter-0.1.0
- equal:
path: stringData.DATA_SOURCE_URI
value: "localhost:5432/postgres?sslmode=disable"
- equal:
path: stringData.DATA_SOURCE_USER
value: "postgres"
- equal:
path: stringData.DATA_SOURCE_PASS
value: "postgres"
- it: Rendering custom annotations and labels.
set:
config.database.secret.annotations:
foo: bar
bar: foo
config.database.secret.databaseUsername: "postgres"
config.database.secret.databasePassword: "postgres"
config.database.secret.databaseConnectionUrl: "localhost:5432/postgres?sslmode=disable"
config.database.secret.labels:
foo: bar
bar: foo
asserts:
- equal:
path: metadata.annotations
value:
foo: bar
bar: foo
- isSubset:
path: metadata.labels
content:
foo: bar
bar: foo