suite: Operator ServiceAccount
templates:
  - serviceaccount.yaml
tests:
  - it: creates no ServiceAccount when operator is not enabled
    values:
      - ../.lint/disabled.yaml
    asserts:
      - hasDocuments:
          count: 0
  - it: creates no ServiceAccount when rbac.create is false
    set:
      serviceAccount:
        create: false
    asserts:
      - hasDocuments:
          count: 0

  - it: creates a ServiceAccount by default
    asserts:
      - containsDocument:
          kind: ServiceAccount
          apiVersion: v1
          name: RELEASE-NAME-teleport-operator

  - it: shortens fullname if .Release.Name == .Chart.Name
    release:
      name: teleport-operator
    asserts:
      - containsDocument:
          kind: ServiceAccount
          apiVersion: v1
          name: teleport-operator

  - it: respects the nameOverride
    set:
      nameOverride: operator
    asserts:
      - containsDocument:
          kind: ServiceAccount
          apiVersion: v1
          name: RELEASE-NAME-operator

  - it: does not shorten fullname if .Release.Name == .Chart.Name but there's a nameOverride
    release:
      name: teleport-operator
    set:
      nameOverride: teleport-operator
    asserts:
      - containsDocument:
          kind: ServiceAccount
          apiVersion: v1
          name: teleport-operator-teleport-operator

  - it: names the ServiceAccount according to serviceAccount.name
    set:
      serviceAccount:
        name: foobar
    asserts:
      - containsDocument:
          kind: ServiceAccount
          apiVersion: v1
          name: foobar
