suite: job spec test
templates:
  - common.yaml
release:
  name: test-release-name
  namespace: test-release-namespace
tests:
  - it: should pass with workload enabled
    set:
      workload:
        workload-name:
          enabled: true
          primary: true
          type: Job
          podSpec: {}
    asserts:
      - documentIndex: &jobDoc 0
        isKind:
          of: Job
      - documentIndex: *jobDoc
        isAPIVersion:
          of: batch/v1
      - documentIndex: *jobDoc
        isSubset:
          path: spec
          content:
            backoffLimit: 5
            completionMode: NonIndexed
            completions:
            parallelism: 1
            ttlSecondsAfterFinished: 120

  - it: should apply spec correctly
    set:
      workload:
        workload-name:
          enabled: true
          primary: true
          type: Job
          backoffLimit: 5
          completionMode: Indexed
          completions: 5
          parallelism: 5
          ttlSecondsAfterFinished: 100
          activeDeadlineSeconds: 100
          podSpec: {}
    asserts:
      - documentIndex: *jobDoc
        isSubset:
          path: spec
          content:
            backoffLimit: 5
            completionMode: Indexed
            completions: 5
            parallelism: 5
            ttlSecondsAfterFinished: 100
            activeDeadlineSeconds: 100
      - documentIndex: *jobDoc
        isSubset:
          path: spec.template.spec
          content:
            restartPolicy: OnFailure

  - it: should set parallelism to 0
    set:
      global:
        stopAll: true
      workload:
        workload-name:
          enabled: true
          primary: true
          type: Job
          parallelism: 0
          podSpec: {}
    asserts:
      - documentIndex: *jobDoc
        isSubset:
          path: spec
          content:
            parallelism: 0

  - it: should set parallelism to 0 on stopAll
    set:
      global:
        stopAll: true
      workload:
        workload-name:
          enabled: true
          primary: true
          type: Job
          parallelism: 3
          podSpec: {}
    asserts:
      - documentIndex: *jobDoc
        isSubset:
          path: spec
          content:
            parallelism: 0
