suite: job validation test
templates:
  - common.yaml
release:
  name: test-release-name
  namespace: test-release-namespace
tests:
  - it: should fail with invalid completionMode
    set:
      workload:
        workload-name:
          enabled: true
          primary: true
          type: Job
          completionMode: not-a-mode
          podSpec: {}
    asserts:
      - failedTemplate:
          errorMessage: Job - Expected [completionMode] to be one of [Indexed, NonIndexed], but got [not-a-mode]

  - it: should fail with completionMode to Indexed and no completions
    set:
      workload:
        workload-name:
          enabled: true
          primary: true
          type: Job
          completionMode: Indexed
          completions:
          podSpec: {}
    asserts:
      - failedTemplate:
          errorMessage: Job - Expected [completions] to be set when [completionMode] is set to [Indexed]

  - it: should fail with completionMode to Indexed and no parallelism
    set:
      workload:
        workload-name:
          enabled: true
          primary: true
          type: Job
          completionMode: Indexed
          completions: 5
          parallelism:
          podSpec: {}
    asserts:
      - failedTemplate:
          errorMessage: Job - Expected [parallelism] to be set when [completionMode] is set to [Indexed]

  - it: should fail with namespace longer than 63 characters
    set:
      workload:
        workload-name:
          enabled: true
          primary: true
          type: Job
          namespace: my-extra-super-duper-long-name-that-is-longer-than-63-characters
          podSpec: {}
    asserts:
      - failedTemplate:
          errorMessage: Job - Namespace [my-extra-super-duper-long-name-that-is-longer-than-63-characters] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters.

  - it: should fail with restartPolicy "Always" for Job
    set:
      workload:
        workload-name:
          enabled: true
          primary: true
          type: Job
          podSpec:
            restartPolicy: Always
    asserts:
      - failedTemplate:
          errorMessage: Expected [restartPolicy] to be one of [Never, OnFailure] for [Job] but got [Always]
