suite: "Controller ServiceAccount validation"
templates:
  - serviceaccount.yaml
  - deployment.yaml
tests:
  - it: should fail if serviceAccount.name is 'default'
    set:
      controller:
        serviceAccount:
          create: true
          name: "default"
    release:
      name: "test-name"
      namespace: "test-namespace"
    asserts:
      - failedTemplate:
          errorMessage: "serviceAccount.name cannot be set to 'default'"
        template: serviceaccount.yaml

  - it: should fail when serviceAccount.create is false and name is not set
    set:
      controller:
        serviceAccount:
          create: false
          name: ""
    release:
      name: "test-name"
      namespace: "test-namespace"
    asserts:
      - failedTemplate:
          errorMessage: "serviceAccount.name must be set if serviceAccount.create is false"
        template: deployment.yaml
