suite: Controller Service Account
release:
  name: my-release
  namespace: my-namespace
templates:
  - service-account-agent.yaml
tests:
  - it: test defaults
    asserts:
    - hasDocuments:
        count: 0
  - it: create service account for agents
    set:
      serviceAccountAgent:
        create: true
    asserts:
      - isKind:
          of: ServiceAccount
      - equal:
          path: apiVersion
          value: v1
      - equal:
          path: metadata.name
          value: my-release-jenkins-agent
      - equal:
          path: metadata.namespace
          value: my-namespace
      - matchRegex:
          path: metadata.labels.helm\.sh/chart
          pattern: ^jenkins-
      - isNull:
          path: metadata.annotations
  - it: agent namespace
    set:
      serviceAccountAgent:
        create: true
        annotations:
          key: value
      agent:
        namespace: agents
    asserts:
      - isKind:
          of: ServiceAccount
      - equal:
          path: apiVersion
          value: v1
      - equal:
          path: metadata.name
          value: my-release-jenkins-agent
      - equal:
          path: metadata.namespace
          value: agents
      - matchRegex:
          path: metadata.labels.helm\.sh/chart
          pattern: ^jenkins-
      - equal:
          path: metadata.annotations
          value:
            key: value
  - it: disable helm.sh label
    set:
      renderHelmLabels: false
      serviceAccountAgent:
        create: true
    asserts:
      - equal:
          path: metadata.labels
          value:
            app.kubernetes.io/component: jenkins-controller
            app.kubernetes.io/instance: my-release
            app.kubernetes.io/managed-by: Helm
            app.kubernetes.io/name: jenkins
  - it: agent image pull secret
    set:
      renderHelmLabels: false
      serviceAccountAgent:
        create: true
        imagePullSecretName: ips-name
    asserts:
      - equal:
          path: imagePullSecrets
          value:
              - name: ips-name
