suite: configmap validation test
templates:
  - common.yaml
release:
  name: test-release-name
  namespace: test-release-namespace
tests:
  - it: should fail with name longer than 253 characters
    set:
      configmap:
        my-configmap-super-long-name-that-is-longer-than-253-characters-my-configmap-super-long-name-that-is-longer-than-253-characters-my-configmap-super-long-name-that-is-longer-than-253-characters-my-configmap-super-long-long-long-long-long-long-long-long-name:
          enabled: true
          data:
            foo: bar
    asserts:
      - failedTemplate:
          errorMessage: Name [test-release-name-common-test-my-configmap-super-long-name-that-is-longer-than-253-characters-my-configmap-super-long-name-that-is-longer-than-253-characters-my-configmap-super-long-name-that-is-longer-than-253-characters-my-configmap-super-long-long-long-long-long-long-long-long-name] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 253 characters.

  - it: should fail with name starting with underscore
    set:
      configmap:
        _my-configmap:
          enabled: true
          data:
            foo: bar
    asserts:
      - failedTemplate:
          errorMessage: Name [test-release-name-common-test-_my-configmap] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 253 characters.

  - it: should fail with namespace longer than 63 characters
    set:
      configmap:
        my-configmap:
          enabled: true
          namespace: my-extra-super-duper-long-name-that-is-longer-than-63-characters
          data:
            foo: bar
    asserts:
      - failedTemplate:
          errorMessage: Configmap - 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 labels not a dict
    set:
      configmap:
        my-configmap:
          enabled: true
          labels: "not a dict"
          data:
            foo: bar
    asserts:
      - failedTemplate:
          errorMessage: ConfigMap - Expected [labels] to be a dictionary, but got [string]

  - it: should fail with annotations not a dict
    set:
      configmap:
        my-configmap:
          enabled: true
          annotations: "not a dict"
          data:
            foo: bar
    asserts:
      - failedTemplate:
          errorMessage: ConfigMap - Expected [annotations] to be a dictionary, but got [string]

  - it: should fail with data not a dict
    set:
      configmap:
        my-configmap:
          enabled: true
          data: "not a dict"
    asserts:
      - failedTemplate:
          errorMessage: ConfigMap - Expected [data] to be a dictionary, but got [string]

  - it: should fail with empty data
    set:
      configmap:
        my-configmap:
          enabled: true
          data: {}
    asserts:
      - failedTemplate:
          errorMessage: ConfigMap - Expected non-empty [data]

  - it: should fail with empty enabled
    set:
      configmap:
        my-configmap:
          enabled:
          data:
            foo: bar
    asserts:
      - failedTemplate:
          errorMessage: ConfigMap - Expected the defined key [enabled] in [configmap.my-configmap] to not be empty
