suite: buffering middleware test
templates:
  - common.yaml
release:
  name: test-release-name
  namespace: test-release-namespace
tests:
  - it: should pass with all set
    set:
      ingressMiddlewares:
        traefik:
          my-middleware1:
            enabled: true
            type: buffering
            data:
              maxRequestBodyBytes: 1024
              memRequestBodyBytes: 1024
              maxResponseBodyBytes: 1024
              memResponseBodyBytes: 1024
              retryExpression: some-expression
    asserts:
      - documentIndex: &middlewareDoc 0
        isKind:
          of: Middleware
      - documentIndex: *middlewareDoc
        equal:
          path: spec
          value:
            buffering:
              maxRequestBodyBytes: 1024
              memRequestBodyBytes: 1024
              maxResponseBodyBytes: 1024
              memResponseBodyBytes: 1024
              retryExpression: "some-expression"

  - it: should pass with only maxRequestBodyBytes set
    set:
      ingressMiddlewares:
        traefik:
          my-middleware1:
            enabled: true
            type: buffering
            data:
              maxRequestBodyBytes: 1024
    asserts:
      - documentIndex: *middlewareDoc
        equal:
          path: spec
          value:
            buffering:
              maxRequestBodyBytes: 1024

  - it: should render 0 and non-null values
    set:
      ingressMiddlewares:
        traefik:
          my-middleware1:
            enabled: true
            type: buffering
            data:
              maxRequestBodyBytes: 0
              memRequestBodyBytes: null
              maxResponseBodyBytes: 1024
              memResponseBodyBytes: 1024
              retryExpression: ""
    asserts:
      - documentIndex: *middlewareDoc
        equal:
          path: spec
          value:
            buffering:
              maxRequestBodyBytes: 0
              maxResponseBodyBytes: 1024
              memResponseBodyBytes: 1024
