suite: Updater Role
templates:
  - updater/role.yaml
tests:
  #
  # Basic tests
  #
  - it: does not create a Role when updater.enabled is false (default)
    asserts:
      - hasDocuments:
          count: 0
  - it: creates a Role when updater.enabled is true
    values:
      - ../.lint/updater.yaml
    asserts:
      - containsDocument:
          kind: Role
          apiVersion: rbac.authorization.k8s.io/v1
          name: RELEASE-NAME-updater
          namespace: NAMESPACE
  - it: does not create a Role when updater.enabled is true but rbac creation is disabled
    values:
      - ../.lint/updater.yaml
    set:
      rbac:
        create: false
    asserts:
      - hasDocuments:
          count: 0

  #
  # Catch-all content test
  #
  - it: sets the correct role rules
    values:
      - ../.lint/updater.yaml
    asserts:
      - matchSnapshot:
          path: rules
