suite: pv data test
templates:
  - common.yaml
release:
  namespace: release-namespace
tests:
  - it: should create nfs pv with csi
    set:
      version: 4.1
      persistence:
        my-volume1:
          enabled: true
          type: nfs-pv-pvc
          server: my-server
          share: /my-path
        my-volume2:
          enabled: true
          type: nfs-pv-pvc
          server: my-server2
          share: /my-path2
          size: 2Gi
          mountOptions:
            - key: hard
            - key: nfsvers
              value: '{{ .Values.version }}'
        my-volume3:
          enabled: true
          type: nfs-pv-pvc
          server: my-server2
          share: /my-path2
          size: 3Gi
          mountOptions:
            - key: hard
            - key: nfsvers
              value: '{{ .Values.version }}'
    asserts:
      - documentIndex: &pvDoc 0
        isKind:
          of: PersistentVolume
      - documentIndex: *pvDoc
        equal:
          path: spec
          value:
            capacity:
              storage: 1Gi
            persistentVolumeReclaimPolicy: Delete
            storageClassName: release-name-common-test-my-volume1-1451165653
            accessModes:
              - ReadWriteOnce
            csi:
              driver: nfs.csi.k8s.io
              volumeHandle: my-server/my-path#release-name-common-test-my-volume1-1451165653
              volumeAttributes:
                server: my-server
                share: /my-path
      - documentIndex: &pvcDoc 1
        isKind:
          of: PersistentVolumeClaim
      - documentIndex: *pvcDoc
        equal:
          path: spec
          value:
            accessModes:
              - ReadWriteOnce
            resources:
              requests:
                storage: 1Gi
            storageClassName: release-name-common-test-my-volume1-1451165653
      - documentIndex: &otherPvDoc 2
        isKind:
          of: PersistentVolume
      - documentIndex: *otherPvDoc
        equal:
          path: spec
          value:
            capacity:
              storage: 2Gi
            persistentVolumeReclaimPolicy: Delete
            storageClassName: release-name-common-test-my-volume2-1702692922
            accessModes:
              - ReadWriteOnce
            mountOptions:
              - hard
              - nfsvers=4.1
            csi:
              driver: nfs.csi.k8s.io
              volumeHandle: my-server2/my-path2#release-name-common-test-my-volume2-1702692922
              volumeAttributes:
                server: my-server2
                share: /my-path2
      - documentIndex: &otherPvcDoc 3
        isKind:
          of: PersistentVolumeClaim
      - documentIndex: *otherPvcDoc
        equal:
          path: spec
          value:
            accessModes:
              - ReadWriteOnce
            resources:
              requests:
                storage: 2Gi
            storageClassName: release-name-common-test-my-volume2-1702692922
      - documentIndex: &thirdPvDoc 4
        isKind:
          of: PersistentVolume
      - documentIndex: *thirdPvDoc
        equal:
          path: spec
          value:
            capacity:
              storage: 3Gi
            persistentVolumeReclaimPolicy: Delete
            storageClassName: release-name-common-test-my-volume3-1704265787
            accessModes:
              - ReadWriteOnce
            mountOptions:
              - hard
              - nfsvers=4.1
            csi:
              driver: nfs.csi.k8s.io
              volumeHandle: my-server2/my-path2#release-name-common-test-my-volume3-1704265787
              volumeAttributes:
                server: my-server2
                share: /my-path2
      - documentIndex: &thirdPvcDoc 5
        isKind:
          of: PersistentVolumeClaim
      - documentIndex: *thirdPvcDoc
        equal:
          path: spec
          value:
            accessModes:
              - ReadWriteOnce
            resources:
              requests:
                storage: 3Gi
            storageClassName: release-name-common-test-my-volume3-1704265787

  - it: should create smb pv with csi
    set:
      version: "3.0"
      persistence:
        my-volume1:
          enabled: true
          type: smb-pv-pvc
          server: my-server
          share: my-share
          username: my-user
          password: my-password
        my-volume2:
          enabled: true
          type: smb-pv-pvc
          server: my-server2
          share: my-share2
          username: my-user2
          password: my-password2
          size: 2Gi
          mountOptions:
            - key: hard
            - key: uid
              value: 99999999999
            - key: vers
              value: '{{ .Values.version }}'
        my-volume3:
          enabled: true
          type: smb-pv-pvc
          server: my-server2
          share: my-share2
          username: my-user2
          password: my-password2
          size: 3Gi
          mountOptions:
            - key: hard
            - key: uid
              value: 99999999999
            - key: vers
              value: '{{ .Values.version }}'
    asserts:
      - documentIndex: &secretDoc 0
        isKind:
          of: Secret
      - documentIndex: *secretDoc
        equal:
          path: stringData
          value:
            username: my-user
            password: my-password
      - documentIndex: &pvDoc 1
        isKind:
          of: PersistentVolume
      - documentIndex: *pvDoc
        equal:
          path: spec
          value:
            capacity:
              storage: 1Gi
            persistentVolumeReclaimPolicy: Delete
            storageClassName: release-name-common-test-my-volume1-1479673868
            accessModes:
              - ReadWriteOnce
            csi:
              driver: smb.csi.k8s.io
              volumeHandle: my-server/my-share#release-name-common-test-my-volume1-1479673868
              volumeAttributes:
                source: //my-server/my-share
              nodeStageSecretRef:
                name: release-name-common-test-my-volume1-1479673868
                namespace: release-namespace
      - documentIndex: &pvcDoc 2
        isKind:
          of: PersistentVolumeClaim
      - documentIndex: *pvcDoc
        equal:
          path: spec
          value:
            accessModes:
              - ReadWriteOnce
            resources:
              requests:
                storage: 1Gi
            storageClassName: release-name-common-test-my-volume1-1479673868
      - documentIndex: &otherSecretDoc 3
        isKind:
          of: Secret
      - documentIndex: *otherSecretDoc
        equal:
          path: stringData
          value:
            username: my-user2
            password: my-password2
      - documentIndex: &otherPvDoc 4
        isKind:
          of: PersistentVolume
      - documentIndex: *otherPvDoc
        equal:
          path: spec
          value:
            capacity:
              storage: 2Gi
            persistentVolumeReclaimPolicy: Delete
            storageClassName: release-name-common-test-my-volume2-1734805617
            accessModes:
              - ReadWriteOnce
            mountOptions:
              - hard
              - uid=99999999999
              - vers=3.0
            csi:
              driver: smb.csi.k8s.io
              volumeHandle: my-server2/my-share2#release-name-common-test-my-volume2-1734805617
              volumeAttributes:
                source: //my-server2/my-share2
              nodeStageSecretRef:
                name: release-name-common-test-my-volume2-1734805617
                namespace: release-namespace
      - documentIndex: &otherPvcDoc 5
        isKind:
          of: PersistentVolumeClaim
      - documentIndex: *otherPvcDoc
        equal:
          path: spec
          value:
            accessModes:
              - ReadWriteOnce
            resources:
              requests:
                storage: 2Gi
            storageClassName: release-name-common-test-my-volume2-1734805617
      - documentIndex: &thirdSecretDoc 6
        isKind:
          of: Secret
      - documentIndex: *thirdSecretDoc
        equal:
          path: stringData
          value:
            username: my-user2
            password: my-password2
      - documentIndex: &thirdPvDoc 7
        isKind:
          of: PersistentVolume
      - documentIndex: *thirdPvDoc
        equal:
          path: spec
          value:
            capacity:
              storage: 3Gi
            persistentVolumeReclaimPolicy: Delete
            storageClassName: release-name-common-test-my-volume3-1736378482
            accessModes:
              - ReadWriteOnce
            mountOptions:
              - hard
              - uid=99999999999
              - vers=3.0
            csi:
              driver: smb.csi.k8s.io
              volumeHandle: my-server2/my-share2#release-name-common-test-my-volume3-1736378482
              volumeAttributes:
                source: //my-server2/my-share2
              nodeStageSecretRef:
                name: release-name-common-test-my-volume3-1736378482
                namespace: release-namespace
      - documentIndex: &thirdPvcDoc 8
        isKind:
          of: PersistentVolumeClaim
      - documentIndex: *thirdPvcDoc
        equal:
          path: spec
          value:
            accessModes:
              - ReadWriteOnce
            resources:
              requests:
                storage: 3Gi
            storageClassName: release-name-common-test-my-volume3-1736378482
