|
| 1 | +# yaml-language-server: $schema=https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json |
| 2 | +suite: ingress spec |
| 3 | +templates: |
| 4 | + - templates/ingress.yaml |
| 5 | +tests: |
| 6 | + - it: Test host and path |
| 7 | + values: |
| 8 | + - values.yaml |
| 9 | + asserts: |
| 10 | + - equal: |
| 11 | + path: spec.rules[0].host |
| 12 | + value: host.domain.local |
| 13 | + - equal: |
| 14 | + path: spec.rules[0].http.paths[0].path |
| 15 | + value: /path |
| 16 | + |
| 17 | + - it: Test service and port |
| 18 | + values: |
| 19 | + - values.yaml |
| 20 | + asserts: |
| 21 | + - equal: |
| 22 | + path: spec.rules[0].http.paths[0].backend.service.name |
| 23 | + value: svc-test |
| 24 | + - equal: |
| 25 | + path: spec.rules[0].http.paths[0].backend.service.port.number |
| 26 | + value: 8080 |
| 27 | + |
| 28 | + - it: Test ingress with template |
| 29 | + values: |
| 30 | + - values.yaml |
| 31 | + set: |
| 32 | + global: |
| 33 | + appUrl: mydomain.example.io |
| 34 | + apiPath: /api |
| 35 | + apiAddr: svc-test-tpl |
| 36 | + apiPort: 8081 |
| 37 | + ingress: |
| 38 | + main: |
| 39 | + enabled: false |
| 40 | + tpl: |
| 41 | + enabled: true |
| 42 | + hosts: |
| 43 | + - host: "{{ .Values.global.appUrl }}" |
| 44 | + paths: |
| 45 | + - path: "{{ .Values.global.apiPath }}" |
| 46 | + service: |
| 47 | + name: "{{ .Values.global.apiAddr }}" |
| 48 | + port: "{{ .Values.global.apiPort }}" |
| 49 | + asserts: |
| 50 | + - hasDocuments: |
| 51 | + count: 1 |
| 52 | + - isKind: |
| 53 | + of: Ingress |
| 54 | + - equal: |
| 55 | + path: spec.rules[0].host |
| 56 | + value: mydomain.example.io |
| 57 | + - equal: |
| 58 | + path: spec.rules[0].http.paths[0].path |
| 59 | + value: /api |
| 60 | + - equal: |
| 61 | + path: spec.rules[0].http.paths[0].backend.service.name |
| 62 | + value: svc-test-tpl |
| 63 | + - equal: |
| 64 | + path: spec.rules[0].http.paths[0].backend.service.port.number |
| 65 | + value: 8081 |
| 66 | + |
| 67 | + - it: Test with no ingressClassName |
| 68 | + values: |
| 69 | + - values.yaml |
| 70 | + asserts: |
| 71 | + - isNull: |
| 72 | + path: spec.ingressClassName |
| 73 | + |
| 74 | + - it: Test with ingressClassName |
| 75 | + values: |
| 76 | + - values.yaml |
| 77 | + set: |
| 78 | + ingress: |
| 79 | + main: |
| 80 | + ingressClassName: nginx |
| 81 | + asserts: |
| 82 | + - equal: |
| 83 | + path: spec.ingressClassName |
| 84 | + value: nginx |
| 85 | + |
| 86 | + - it: Test with no tls |
| 87 | + values: |
| 88 | + - values.yaml |
| 89 | + asserts: |
| 90 | + - isNull: |
| 91 | + path: spec.tls |
| 92 | + |
| 93 | + - it: Test with tls enabled |
| 94 | + values: |
| 95 | + - values.yaml |
| 96 | + set: |
| 97 | + ingress: |
| 98 | + main: |
| 99 | + tls: |
| 100 | + - secretName: secret-example-tls |
| 101 | + hosts: |
| 102 | + - host.domain.local |
| 103 | + asserts: |
| 104 | + - contains: |
| 105 | + path: spec.tls |
| 106 | + content: |
| 107 | + secretName: secret-example-tls |
| 108 | + hosts: |
| 109 | + - host.domain.local |
| 110 | + |
| 111 | + - it: Test with tls enabled with template |
| 112 | + values: |
| 113 | + - values.yaml |
| 114 | + set: |
| 115 | + global: |
| 116 | + appUrl: mydomain.example.io |
| 117 | + secretName: secret-example-tls-tpl |
| 118 | + ingress: |
| 119 | + main: |
| 120 | + tls: |
| 121 | + - secretName: "{{ .Values.global.secretName }}" |
| 122 | + hosts: |
| 123 | + - "{{ .Values.global.appUrl }}" |
| 124 | + asserts: |
| 125 | + - contains: |
| 126 | + path: spec.tls |
| 127 | + content: |
| 128 | + secretName: secret-example-tls-tpl |
| 129 | + hosts: |
| 130 | + - mydomain.example.io |
| 131 | + |
| 132 | + - it: Test with multiple ingress |
| 133 | + values: |
| 134 | + - values.yaml |
| 135 | + set: |
| 136 | + ingress: |
| 137 | + second: |
| 138 | + enabled: true |
| 139 | + hosts: |
| 140 | + - host: host.domain.local |
| 141 | + paths: |
| 142 | + - path: /another/path |
| 143 | + pathType: ImplementationSpecific |
| 144 | + service: |
| 145 | + name: svc-test |
| 146 | + port: 8081 |
| 147 | + asserts: |
| 148 | + - hasDocuments: |
| 149 | + count: 2 |
| 150 | + - isKind: |
| 151 | + of: Ingress |
| 152 | + documentIndex: 0 |
| 153 | + - isKind: |
| 154 | + of: Ingress |
| 155 | + documentIndex: 1 |
| 156 | + |
| 157 | + - it: Test multiple paths |
| 158 | + values: |
| 159 | + - values.yaml |
| 160 | + set: |
| 161 | + ingress: |
| 162 | + main: |
| 163 | + hosts: |
| 164 | + - host: host.domain.local |
| 165 | + paths: |
| 166 | + - path: /path/one |
| 167 | + service: |
| 168 | + name: svc-test-one |
| 169 | + port: 8080 |
| 170 | + - path: /path/two |
| 171 | + service: |
| 172 | + name: svc-test-two |
| 173 | + port: 8081 |
| 174 | + asserts: |
| 175 | + - lengthEqual: |
| 176 | + path: spec.rules[0].http.paths |
| 177 | + count: 2 |
| 178 | + |
| 179 | + - it: Test multiple hosts |
| 180 | + values: |
| 181 | + - values.yaml |
| 182 | + set: |
| 183 | + ingress: |
| 184 | + main: |
| 185 | + hosts: |
| 186 | + - host: host-one.domain.local |
| 187 | + paths: |
| 188 | + - path: /path/one |
| 189 | + service: |
| 190 | + name: svc-test-one |
| 191 | + port: 8080 |
| 192 | + - host: host-two.domain.local |
| 193 | + paths: |
| 194 | + - path: /path/two |
| 195 | + service: |
| 196 | + name: svc-test-two |
| 197 | + port: 8081 |
| 198 | + asserts: |
| 199 | + - lengthEqual: |
| 200 | + path: spec.rules |
| 201 | + count: 2 |
| 202 | + |
| 203 | + - it: Test with no ingresses |
| 204 | + values: |
| 205 | + - values.yaml |
| 206 | + set: |
| 207 | + ingress: |
| 208 | + main: |
| 209 | + enabled: false |
| 210 | + asserts: |
| 211 | + - hasDocuments: |
| 212 | + count: 0 |
0 commit comments