suite: PersistentVolumeClaim
release:
  name: my-release
  namespace: my-namespace
templates:
  - home-pvc.yaml
tests:
  - it: tests defaults
    asserts:
      - isKind:
          of: PersistentVolumeClaim
      - equal:
          path: apiVersion
          value: v1
      - equal:
          path: metadata.name
          value: my-release-jenkins
      - equal:
          path: metadata.namespace
          value: my-namespace
      - matchRegex:
          path: metadata.labels.helm\.sh/chart
          pattern: ^jenkins-
      - isNull:
          path: metadata.annotations
      - contains:
          path: spec.accessModes
          content: ReadWriteOnce
      - equal:
          path: spec.resources.requests
          value:
            storage: 8Gi
      - isNull:
          path: spec.storageClassName
            
  - it: test different values
    set:
      persistence:
        annotations:
          my-annotation: value
        accessMode: ReadWriteMany
        size: 20Gi
        storageClass: gp2
    asserts:
      - equal:
          path: metadata.annotations
          value:
            my-annotation: value
      - contains:
          path: spec.accessModes
          content: ReadWriteMany
      - equal:
          path: spec.resources.requests
          value:
            storage: 20Gi
      - equal:
          path: spec.storageClassName
          value: gp2

  - it: existing claim
    set:
      persistence:
        existingClaim: my-pvc
    asserts:
    - hasDocuments:
        count: 0

  - it: disable helm.sh label
    set:
      renderHelmLabels: false
    asserts:
      - equal:
          path: metadata.labels
          value:
            app.kubernetes.io/component: jenkins-controller
            app.kubernetes.io/instance: my-release
            app.kubernetes.io/managed-by: Helm
            app.kubernetes.io/name: jenkins

  - it: add label
    set:
      renderHelmLabels: false
      persistence:
        labels:
          test-label: test-value
    asserts:
      - equal:
          path: metadata.labels
          value:
            app.kubernetes.io/component: jenkins-controller
            app.kubernetes.io/instance: my-release
            app.kubernetes.io/managed-by: Helm
            app.kubernetes.io/name: jenkins
            test-label: test-value
