suite: secret data test
templates:
  - common.yaml
release:
  name: test-release-name
  namespace: test-release-namespace
tests:
  - it: should pass with key-value data
    set:
      secret:
        my-secret1:
          enabled: true
          data:
            foo: bar
    asserts:
      - documentIndex: &secretDoc 0
        isKind:
          of: Secret
      - documentIndex: *secretDoc
        equal:
          path: stringData
          value:
            foo: bar
      - documentIndex: *secretDoc
        equal:
          path: type
          value: Opaque

  - it: should pass with custom secret type
    set:
      secret:
        my-secret1:
          enabled: true
          type: SomeCustomType
          data:
            foo: bar
    asserts:
      - documentIndex: *secretDoc
        equal:
          path: type
          value: SomeCustomType

  - it: should pass with key-value data from tpl
    set:
      data: bar
      secret:
        my-secret1:
          enabled: true
          data:
            foo: "{{ .Values.data }}"
    asserts:
      - documentIndex: *secretDoc
        equal:
          path: stringData
          value:
            foo: bar

  - it: should pass with scalar data
    set:
      secret:
        my-secret1:
          enabled: true
          data:
            foo: |
              some multi line
              string text
    asserts:
      - documentIndex: *secretDoc
        equal:
          path: stringData
          value:
            foo: |
              some multi line
              string text

  - it: should pass with scalar data with tpl
    set:
      data: Some other text
      secret:
        my-secret:
          enabled: true
          data:
            foo: |
              file start
              {{ .Values.data }}
    asserts:
      - documentIndex: *secretDoc
        equal:
          path: stringData
          value:
            foo: |
              file start
              Some other text

  - it: should pass with scalar data from tpl
    set:
      data: |
        Some other text
        some_text
      secret:
        my-secret:
          enabled: true
          data:
            foo: |
              {{- .Values.data | nindent 2 }}
    asserts:
      - documentIndex: *secretDoc
        equal:
          path: stringData
          value:
            foo: |
              Some other text
              some_text

  - it: should pass with empty data on kubernetes.io/service-account-token type
    set:
      secret:
        my-secret:
          enabled: true
          type: kubernetes.io/service-account-token
    asserts:
      - documentIndex: *secretDoc
        equal:
          path: stringData
          value: null
