suite: cnpg stop test
templates:
  - common.yaml
release:
  name: test-release-name
  namespace: test-release-namespace
tests:
  - it: should pass with hibernate
    set:
      cnpg:
        mypg:
          enabled: true
          user: app
          database: app
          password: test-password
          instances: 2
          hibernate: true
          pooler:
            enabled: true
    asserts:
      - documentIndex: &clusterDoc 1
        isKind:
          of: Cluster
      - documentIndex: *clusterDoc
        isAPIVersion:
          of: postgresql.cnpg.io/v1
      - documentIndex: *clusterDoc
        isSubset:
          path: metadata.annotations
          content:
            cnpg.io/hibernation: "on"
      - documentIndex: &poolerDoc 0
        isKind:
          of: Pooler
      - documentIndex: *poolerDoc
        isAPIVersion:
          of: postgresql.cnpg.io/v1
      - documentIndex: *poolerDoc
        isSubset:
          path: spec
          content:
            instances: 0

  - it: should set hibernate and 0 instances on stopAll
    set:
      global:
        stopAll: true
      cnpg:
        mypg:
          enabled: true
          user: app
          database: app
          password: test-password
          hibernate: false
          instances: 2
          pooler:
            enabled: true
    asserts:
      - documentIndex: *clusterDoc
        isKind:
          of: Cluster
      - documentIndex: *clusterDoc
        isAPIVersion:
          of: postgresql.cnpg.io/v1
      - documentIndex: *clusterDoc
        isSubset:
          path: metadata.annotations
          content:
            cnpg.io/hibernation: "on"
      - documentIndex: *poolerDoc
        isKind:
          of: Pooler
      - documentIndex: *poolerDoc
        isAPIVersion:
          of: postgresql.cnpg.io/v1
      - documentIndex: *poolerDoc
        isSubset:
          path: spec
          content:
            instances: 0
