suite: pod termination grace period test
templates:
  - common.yaml
tests:
  - it: should pass with empty terminationGracePeriodSeconds
    set:
      podOptions:
        terminationGracePeriodSeconds: ""
      workload:
        workload-name1:
          enabled: true
          primary: true
          type: Deployment
          podSpec: {}
    asserts:
      - documentIndex: &deploymentDoc 0
        isKind:
          of: Deployment
      - documentIndex: *deploymentDoc
        isNull:
          path: spec.template.spec.terminationGracePeriodSeconds

  - it: should pass with terminationGracePeriodSeconds from "global"
    set:
      podOptions:
        terminationGracePeriodSeconds: 100
      workload:
        workload-name1:
          enabled: true
          primary: true
          type: Deployment
          podSpec: {}
    asserts:
      - documentIndex: *deploymentDoc
        equal:
          path: spec.template.spec.terminationGracePeriodSeconds
          value: 100

  - it: should pass with terminationGracePeriodSeconds from "pod"
    set:
      podOptions:
        terminationGracePeriodSeconds: 100
      workload:
        workload-name1:
          enabled: true
          primary: true
          type: Deployment
          podSpec:
            terminationGracePeriodSeconds: 150
    asserts:
      - documentIndex: *deploymentDoc
        equal:
          path: spec.template.spec.terminationGracePeriodSeconds
          value: 150

  - it: should pass with terminationGracePeriodSeconds from "pod" with tpl
    set:
      period: 125
      podOptions:
        terminationGracePeriodSeconds: 50
      workload:
        workload-name1:
          enabled: true
          primary: true
          type: Deployment
          podSpec:
            terminationGracePeriodSeconds: "{{ .Values.period }}"
    asserts:
      - documentIndex: *deploymentDoc
        equal:
          path: spec.template.spec.terminationGracePeriodSeconds
          value: 125
