suite: test service account
templates:
  - serviceaccount.yaml
release:
  name: oncall
tests:
  - it: serviceAccount.create=true -> should create serviceAccount (default)
    asserts:
      - containsDocument:
          kind: ServiceAccount
          apiVersion: v1
          name: oncall
      - notExists:
          path: metadata.annotations
      - isSubset:
          path: metadata.labels
          content:
            app.kubernetes.io/instance: oncall
            app.kubernetes.io/name: oncall

  - it: serviceAccount.create=false -> should not create serviceAccount
    set:
      serviceAccount.create: false
    asserts:
      - hasDocuments:
          count: 0

  - it: serviceAccount.name=custom -> should create custom serviceAccount
    set:
      serviceAccount.name: custom
    asserts:
      - equal:
          path: metadata.name
          value: custom

  - it: serviceAccount.annotations -> should add annotations to serviceAccount
    set:
      serviceAccount.annotations:
        some-annotation: some-value
    asserts:
      - isSubset:
          path: metadata.annotations
          content:
            some-annotation: some-value

  - it: migrate.useHook=>true -> should add "helm.sh/hook" annotations to serviceAccount
    set:
      migrate.useHook: true
    asserts:
      - isSubset:
          path: metadata.annotations
          content:
            "helm.sh/hook": pre-install,pre-upgrade
            "helm.sh/hook-weight": "-5"
