suite: Controller > DaemonSet
templates:
  - controller-daemonset.yaml

tests:
  - it: should create a DaemonSet if `controller.kind` is "DaemonSet"
    set:
      controller.kind: DaemonSet
      kind: Vanilla
    asserts:
      - hasDocuments:
          count: 1
      - isKind:
          of: DaemonSet
      - equal:
          path: metadata.name
          value: RELEASE-NAME-open-appsec-k8s-nginx-ingress-controller

  - it: should create a DaemonSet with argument `--enable-metrics=false` if `controller.metrics.enabled` is false
    set:
      controller.kind: DaemonSet
      kind: Vanilla
      controller.metrics.enabled: false
    asserts:
      - contains:
          path: spec.template.spec.containers[0].args
          content: --enable-metrics=false

  - it: should create a DaemonSet without argument `--enable-metrics=false` if `controller.metrics.enabled` is true
    set:
      controller.kind: DaemonSet
      kind: Vanilla
      controller.metrics.enabled: true
    asserts:
      - notContains:
          path: spec.template.spec.containers[0].args
          content: --enable-metrics=false

  - it: should create a DaemonSet with resource limits if `controller.resources.limits` is set
    set:
      controller.kind: DaemonSet
      kind: Vanilla
      controller.resources.limits.cpu: 500m
      controller.resources.limits.memory: 512Mi
    asserts:
      - equal:
          path: spec.template.spec.containers[0].resources.limits.cpu
          value: 500m
      - equal:
          path: spec.template.spec.containers[0].resources.limits.memory
          value: 512Mi
