suite: test migrate annotations
templates:
  - engine/job-migrate.yaml
release:
  name: oncall
tests:
  - it: migrate.useHook=false -> should not provide an annotations block
    set:
      migrate.useHook: false
    asserts:
      - notExists:
          path: metadata.annotations

  - it: migrate.useHook=true -> should provide the "helm.sh/hook" annotations
    set:
      migrate.useHook: true
    asserts:
      - equal:
          path: metadata.annotations
          value:
            "helm.sh/hook": pre-install,pre-upgrade
            "helm.sh/hook-weight": "-1"

  - it: migrate.useHook=false and annotations set -> should only contain the custom annotations
    set:
      migrate.useHook: false
      migrate.annotations:
        some-annotation: some-value
        other-annotation: other-value
    asserts:
      - equal:
          path: metadata.annotations
          value:
            some-annotation: some-value
            other-annotation: other-value

  - it: >
      migrate.useHook=true and annotations set -> should contain the custom annotations
      and the "helm.sh/hook" annotations
    set:
      migrate.useHook: true
      migrate.annotations:
        some-annotation: some-value
        other-annotation: other-value
    asserts:
      - equal:
          path: metadata.annotations
          value:
            "helm.sh/hook": pre-install,pre-upgrade
            "helm.sh/hook-weight": "-1"
            some-annotation: some-value
            other-annotation: other-value
