---
suite: test storage class behavior
templates:
  - statefulset.yaml
tests:
  - it: 'should render "" as storageClassname (global case)'
    values:
      - ./values/persistence.yaml
    set:
      global.persistence.storageClass: "-"
    asserts:
      - isEmpty:
          path: spec.volumeClaimTemplates[0].spec.storageClassName

  - it: 'should "" as storageClassname (override case)'
    values:
      - ./values/persistence.yaml
    set:
      global.persistence.storageClass: "global"
      persistence.storageClassOverride: "-"
    asserts:
      - isEmpty:
          path: spec.volumeClaimTemplates[0].spec.storageClassName

  - it: 'should "" as storageClassname (local case)'
    values:
      - ./values/persistence.yaml
    set:
      persistence.storageClass: "-"
    asserts:
      - isEmpty:
          path: spec.volumeClaimTemplates[0].spec.storageClassName

  - it: 'should render "global" as storageClassname'
    values:
      - ./values/persistence.yaml
    set:
      global.persistence.storageClass: "global"
    asserts:
      - equal:
          path: spec.volumeClaimTemplates[0].spec.storageClassName
          value: "global"

  - it: 'should render "local" as storageClassname'
    values:
      - ./values/persistence.yaml
    asserts:
      - equal:
          path: spec.volumeClaimTemplates[0].spec.storageClassName
          value: "local"

  - it: 'should render "override" as storageClassname'
    values:
      - ./values/persistence.yaml
    set:
      global.persistence.storageClass: "global"
      persistence.storageClassOverride: "override"
    asserts:
      - equal:
          path: spec.volumeClaimTemplates[0].spec.storageClassName
          value: "override"

  - it: 'should render "RELEASE-NAME-mariadb-galera-data" as storageClassname'
    asserts:
      - equal:
          path: spec.volumeClaimTemplates[0].spec.storageClassName
          value: "RELEASE-NAME-mariadb-galera-data"