suite: Jenkins Controller
release:
  name: my-release
  namespace: my-namespace
templates:
  - jenkins-controller-svc.yaml
tests:
  - it: default tests
    asserts:
      - isKind:
          of: Service
      - equal:
          path: apiVersion
          value: v1
      - equal:
          path: metadata.name
          value: my-release-jenkins
      - equal:
          path: metadata.namespace
          value: my-namespace
      - matchRegex:
          path: metadata.labels.helm\.sh/chart
          pattern: ^jenkins-
      - isNull:
          path: metadata.annotations
      - equal:
          path: spec
          value:
            ports:
            - name: http
              port: 8080
              targetPort: 8080
            selector:
              app.kubernetes.io/component: jenkins-controller
              app.kubernetes.io/instance: my-release
            type: ClusterIP
  - it: other values
    set:
      controller:
        serviceLabels:
          label: label-value
        serviceAnnotations:
          key: value
        clusterIP: 10.10.10.11
        servicePort: 8888
        targetPort: 7777
        extraPorts:
          - name: BuildInfoProxy
            port: 9000
    asserts:
      - equal:
          path: metadata.labels.label
          value: label-value
      - equal:
          path: metadata.annotations
          value:
            key: value
      - equal:
          path: spec
          value:
            clusterIP: 10.10.10.11
            ports:
            - name: http
              port: 8888
              targetPort: 7777
            - name: BuildInfoProxy
              port: 9000
              targetPort: 9000
            selector:
              app.kubernetes.io/component: jenkins-controller
              app.kubernetes.io/instance: my-release
            type: ClusterIP
  - it: extraPort with targetPort
    set:
      controller:
        serviceLabels:
          label: label-value
        serviceAnnotations:
          key: value
        clusterIP: 10.10.10.11
        servicePort: 8888
        targetPort: 7777
        extraPorts:
          - name: https
            port: 443
            targetPort: 8080
    asserts:
      - equal:
          path: metadata.labels.label
          value: label-value
      - equal:
          path: metadata.annotations
          value:
            key: value
      - equal:
          path: spec
          value:
            clusterIP: 10.10.10.11
            ports:
            - name: http
              port: 8888
              targetPort: 7777
            - name: https
              port: 443
              targetPort: 8080
            selector:
              app.kubernetes.io/component: jenkins-controller
              app.kubernetes.io/instance: my-release
            type: ClusterIP
  - it: node port
    set:
      controller:
        serviceType: NodePort
        nodePort: 11111
    asserts:
       - equal:
          path: spec
          value:
            ports:
            - name: http
              port: 8080
              targetPort: 8080
              nodePort: 11111
            selector:
              app.kubernetes.io/component: jenkins-controller
              app.kubernetes.io/instance: my-release
            type: NodePort
  - it: load balancer
    set:
      controller:
        serviceType: LoadBalancer
        loadBalancerIP: 10.10.10.10
    asserts:
       - equal:
          path: spec
          value:
            loadBalancerIP: 10.10.10.10
            loadBalancerSourceRanges:
              - 0.0.0.0/0
            ports:
            - name: http
              port: 8080
              targetPort: 8080
            selector:
              app.kubernetes.io/component: jenkins-controller
              app.kubernetes.io/instance: my-release
            type: LoadBalancer
  - it: disable helm.sh label
    set:
      renderHelmLabels: false
    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
