Abstract
Documentation of the unit tests for this repository.
PostgreSQL Unit Tests#
Tests Usage#
To run these tests you need to install the unittest plugin.
Install the plugin.
helm plugin install https://github.com/helm-unittest/helm-unittest
Run the tests.
helm unittest -f 'tests/*.yaml' .
Service Test#
- suite
PostgreSQL Service Test Suite
Tests for the Service template.
tests/service_test_suite.yaml#suite: PostgreSQL Service Test Suite release: name: postgresql set: service: enabled: true templates: - "templates/service.yaml" values: - ../values.yaml tests: - it: "should render Service with correct metadata" asserts: - isKind: of: Service - matchRegex: path: metadata.name pattern: "^postgresql.*$" - equal: path: metadata.labels value: app.kubernetes.io/component: database app.kubernetes.io/instance: postgresql app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: postgresql app.kubernetes.io/version: "16.3" helm.sh/chart: postgresql-0.0.3 - it: "should render Service with correct spec configurations" asserts: - equal: path: spec.type value: "LoadBalancer" - equal: path: spec.ports[0].port value: 5432 - equal: path: spec.ports[0].targetPort value: 5432 - equal: path: spec.ports[0].protocol value: "TCP" - equal: path: spec.ports[0].name value: "postgresql" - equal: path: spec.selector value: app.kubernetes.io/component: database app.kubernetes.io/instance: postgresql app.kubernetes.io/name: postgresql
ServiceAccount Test#
- suite
ServiceAccount Test Suite
Tests for the PostgreSQL ServiceAccount.
tests/serviceaccount_test_suite.yaml## :start-at: "suite: PostgreSQL ServiceAccount Test Suite" # ``` suite: PostgreSQL ServiceAccount Test Suite release: name: postgresql templates: - "templates/serviceaccount.yaml" values: - ../values.yaml tests: - it: "should render ServiceAccount with correct metadata" asserts: - isKind: of: ServiceAccount - equal: path: metadata.name value: postgresql - equal: path: metadata.labels value: app.kubernetes.io/component: database app.kubernetes.io/instance: postgresql app.kubernetes.io/name: postgresql - equal: path: metadata.annotations value: app.kubernetes.io/name: postgresql - it: "should render ServiceAccount with correct spec configurations" asserts: - equal: path: automountServiceAccountToken value: true
StatefulSet Test#
- suite
StatefulSet Test
Tests the StatefulSet template values.
tests/statefulset_test.yaml## :start-at: "suite: PostgreSQL StatefulSet Test Suite" # ``` suite: PostgreSQL StatefulSet Test Suite release: name: postgresql templates: - "templates/statefulset.yaml" set: type: StatefulSet values: - ../values.yaml tests: - it: "should render StatefulSet with correct metadata" asserts: - isKind: of: StatefulSet - equal: path: metadata.name value: postgresql - it: should render statefulset correctly asserts: - matchSnapshot: path: spec