suite: chain 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: chain
            data:
              middlewares:
                - name: some-name
                  expandObjectName: false
                - name: some-other-name
    asserts:
      - documentIndex: &middlewareDoc 0
        isKind:
          of: Middleware
      - documentIndex: *middlewareDoc
        equal:
          path: spec
          value:
            chain:
              middlewares:
                - name: some-name
                - name: test-release-name-common-test-some-other-name

  - it: should fail with missing middlewares
    set:
      ingressMiddlewares:
        traefik:
          my-middleware1:
            enabled: true
            type: chain
            data:
              middlewares: []
    asserts:
      - failedTemplate:
          errorMessage: Middleware (chain) - Expected [middlewares] to be set
