suite: volsync replication dest metadata test
templates:
  - common.yaml
chart:
  appVersion: &appVer v9.9.9
release:
  name: test-release-name
  namespace: test-release-namespace
tests:
  - it: should pass with replication dest created with labels and annotations
    set:
      label1: label1
      label2: global_label2
      annotation1: annotation1
      annotation2: global_annotation2
      global:
        labels:
          g_label1: global_label1
          g_label2: "{{ .Values.label2 }}"
        annotations:
          g_annotation1: global_annotation1
          g_annotation2: "{{ .Values.annotation2 }}"
      persistence:
        destbackup:
          enabled: true
          type: pvc
          mountPath: /backedup
          volsync:
            - name: mybackup
              type: restic
              credentials: mys3
              src:
                enabled: false
              dest:
                enabled: true
              labels:
                label1: "{{ .Values.label1 }}"
                label2: label2
              annotations:
                annotation1: "{{ .Values.annotation1 }}"
                annotation2: annotation2
      credentials:
        mys3:
          type: s3
          url: http://some-url
          bucket: some-bucket
          encrKey: some-key
          accessKey: some-access-key
          secretKey: some-secret-key
    asserts:
      - documentIndex: &secretDoc 0
        isKind:
          of: Secret
      - documentIndex: *secretDoc
        isAPIVersion:
          of: v1
      - documentIndex: *secretDoc
        equal:
          path: metadata.annotations
          value:
            annotation1: annotation1
            annotation2: annotation2
            g_annotation1: global_annotation1
            g_annotation2: global_annotation2
      - documentIndex: *secretDoc
        equal:
          path: metadata.labels
          value:
            app: common-test-1.0.0
            release: test-release-name
            helm-revision: "0"
            helm.sh/chart: common-test-1.0.0
            app.kubernetes.io/name: common-test
            app.kubernetes.io/instance: test-release-name
            app.kubernetes.io/managed-by: Helm
            app.kubernetes.io/version: *appVer
            g_label1: global_label1
            g_label2: global_label2
            label1: label1
            label2: label2
      - documentIndex: &replicationDestDoc 1
        isKind:
          of: ReplicationDestination
      - documentIndex: *replicationDestDoc
        isAPIVersion:
          of: volsync.backube/v1alpha1
      - documentIndex: *replicationDestDoc
        equal:
          path: metadata.annotations
          value:
            annotation1: annotation1
            annotation2: annotation2
            g_annotation1: global_annotation1
            g_annotation2: global_annotation2
      - documentIndex: *replicationDestDoc
        equal:
          path: metadata.labels
          value:
            app: common-test-1.0.0
            release: test-release-name
            helm-revision: "0"
            helm.sh/chart: common-test-1.0.0
            app.kubernetes.io/name: common-test
            app.kubernetes.io/instance: test-release-name
            app.kubernetes.io/managed-by: Helm
            app.kubernetes.io/version: *appVer
            g_label1: global_label1
            g_label2: global_label2
            label1: label1
            label2: label2
