suite: Controller Secondary Ingress
release:
  name: my-release
  namespace: my-namespace
templates:
  - jenkins-controller-secondary-ingress.yaml
capabilities:
  majorVersion: 1
  minorVersion: 18 
tests:
  - it: test defaults
    asserts:
    - hasDocuments:
        count: 0
  - it: enabled
    set:
      controller.secondaryingress:
        enabled: true
        hostName: jenkins.example.com
        ingressClassName: nginx
        paths:
          - /github-webhook
        tls:
          - secretName: tlsSecret
            hosts:
              - jenkins.example.com
    asserts:
      - isKind:
          of: Ingress
      - equal:
          path: apiVersion
          value: networking.k8s.io/v1beta1
      - equal:
          path: metadata.name
          value: my-release-jenkins-secondary
      - equal:
          path: metadata.namespace
          value: my-namespace
      - matchRegex:
          path: metadata.labels.helm\.sh/chart
          pattern: ^jenkins-
      - isNull:
          path: metadata.annotations
      - equal:
          path: spec
          value:
            ingressClassName: nginx
            rules:
              - host: jenkins.example.com
                http:
                  paths:
                    - backend:
                        serviceName: my-release-jenkins
                        servicePort: 8080
                      path: /github-webhook
            tls:
            - hosts:
              - jenkins.example.com
              secretName: tlsSecret
  - it: disable helm.sh label
    set:
      renderHelmLabels: false
      controller.secondaryingress:
        enabled: true
        hostName: jenkins.example.com
        ingressClassName: nginx
        paths:
          - /github-webhook
    asserts:
      - equal:
          path: metadata.labels
          value:
            app.kubernetes.io/component: jenkins-controller
            app.kubernetes.io/instance: my-release
            app.kubernetes.io/managed-by: Helm
            app.kubernetes.io/name: jenkins
