chart:
  appVersion: 0.1.0
  version: 0.1.0
suite: ServiceAccount prometheus-postgres-exporter template (basic)
release:
  name: prometheus-postgres-exporter-unittest
  namespace: testing
templates:
- templates/prometheus-postgres-exporter/serviceAccount.yaml
tests:
- it: Skip rendering.
  set:
    serviceAccount.existing.enabled: true
  asserts:
  - hasDocuments:
      count: 0

- it: Rendering serviceAccount with default values.
  asserts:
  - hasDocuments:
      count: 1
  - containsDocument:
      apiVersion: v1
      kind: ServiceAccount
      name: prometheus-postgres-exporter-unittest
      namespace: testing
  - notExists:
      path: metadata.annotations
  - notExists:
      path: metadata.labels
  - equal:
      path: automountServiceAccountToken
      value: true
  - notExists:
      path: imagePullSecrets
  - notExists:
      path: secrets


- it: Rendering serviceAccount with custom values.
  set:
    serviceAccount.new.annotations:
      foo: bar
    serviceAccount.new.labels:
      bar: foo
    serviceAccount.new.automountServiceAccountToken: false
    serviceAccount.new.imagePullSecrets:
    - name: "my-pull-secret"
    serviceAccount.new.secrets:
    - name: "my-secret"
      namespace: "my-namespace"
      fieldPath: "my-path"
  asserts:
  - hasDocuments:
      count: 1
  - exists:
      path: metadata.annotations
      value:
        foo: bar
  - exists:
      path: metadata.labels
      value:
        bar: foo
  - equal:
      path: metadata.name
      value: prometheus-postgres-exporter-unittest
  - equal:
      path: automountServiceAccountToken
      value: false
  - equal:
      path: imagePullSecrets
      value:
        - name: "my-pull-secret"
  - equal:
      path: secrets
      value:
      - name: "my-secret"
        namespace: "my-namespace"
        fieldPath: "my-path"