|
| 1 | +# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json |
| 2 | +suite: httproute test |
| 3 | +templates: |
| 4 | + - templates/httproute.yaml |
| 5 | + - templates/tunnel-client.yaml |
| 6 | + - templates/codefresh-cm.yaml |
| 7 | +tests: |
| 8 | +- it: no httproute is rendered when tunnel runtime is configured |
| 9 | + template: templates/httproute.yaml |
| 10 | + values: |
| 11 | + - ./values/mandatory-values.yaml |
| 12 | + asserts: |
| 13 | + - hasDocuments: |
| 14 | + count: 0 |
| 15 | + |
| 16 | +- it: no tunnel when httproute is configured |
| 17 | + template: templates/tunnel-client.yaml |
| 18 | + values: |
| 19 | + - ./values/mandatory-values-httproute.yaml |
| 20 | + asserts: |
| 21 | + - hasDocuments: |
| 22 | + count: 0 |
| 23 | + |
| 24 | +- it: httproute is rendered correctly when enabled |
| 25 | + template: templates/httproute.yaml |
| 26 | + values: |
| 27 | + - ./values/mandatory-values-httproute.yaml |
| 28 | + asserts: |
| 29 | + - hasDocuments: |
| 30 | + count: 1 |
| 31 | + - equal: |
| 32 | + path: spec.parentRefs |
| 33 | + value: |
| 34 | + - name: traefik-gateway |
| 35 | + namespace: traefik |
| 36 | + - equal: |
| 37 | + path: spec.hostnames |
| 38 | + value: |
| 39 | + - runtime.example.com |
| 40 | + - equal: |
| 41 | + path: spec.rules |
| 42 | + value: |
| 43 | + - matches: |
| 44 | + - path: |
| 45 | + type: PathPrefix |
| 46 | + value: /webhooks |
| 47 | + - path: |
| 48 | + type: PathPrefix |
| 49 | + value : /app-proxy |
| 50 | + - path: |
| 51 | + type: PathPrefix |
| 52 | + value : /workflows |
| 53 | + backendRefs: |
| 54 | + - name: internal-router |
| 55 | + port: 80 |
| 56 | + |
| 57 | +- it: httroute has custom labels and annotations |
| 58 | + template: templates/httproute.yaml |
| 59 | + values: |
| 60 | + - ./values/mandatory-values-httproute.yaml |
| 61 | + set: |
| 62 | + global: |
| 63 | + runtime: |
| 64 | + httpRoute: |
| 65 | + labels: |
| 66 | + customLabel: customValue |
| 67 | + annotations: |
| 68 | + customAnnotation: customAnnotationValue |
| 69 | + asserts: |
| 70 | + - equal: |
| 71 | + path: metadata.labels.customLabel |
| 72 | + value: customValue |
| 73 | + - equal: |
| 74 | + path: metadata.annotations.customAnnotation |
| 75 | + value: customAnnotationValue |
| 76 | + |
| 77 | +- it: codefresh-cm ingressHost is set correctly when httproute is enabled |
| 78 | + template: templates/codefresh-cm.yaml |
| 79 | + values: |
| 80 | + - ./values/mandatory-values-httproute.yaml |
| 81 | + asserts: |
| 82 | + - equal: |
| 83 | + path: data.ingressHost |
| 84 | + value: https://runtime.example.com |
| 85 | + |
| 86 | +- it: error is thrown when httpRoute is enabled but parentRefs is missing |
| 87 | + template: templates/httproute.yaml |
| 88 | + values: |
| 89 | + - ./values/mandatory-values-httproute.yaml |
| 90 | + set: |
| 91 | + global.runtime.httpRoute.parentRefs: null |
| 92 | + asserts: |
| 93 | + - failedTemplate: |
| 94 | + errorMessage: "ERROR: global.runtime.httpRoute.parentRefs is required when httpRoute is enabled" |
| 95 | + |
| 96 | +- it: error is thrown when httpRoute is enabled but hostnames is missing |
| 97 | + template: templates/httproute.yaml |
| 98 | + values: |
| 99 | + - ./values/mandatory-values-httproute.yaml |
| 100 | + set: |
| 101 | + global.runtime.httpRoute.hostnames: null |
| 102 | + asserts: |
| 103 | + - failedTemplate: |
| 104 | + errorMessage: "ERROR: global.runtime.httpRoute.hostnames is required when httpRoute is enabled" |
0 commit comments