| 186 | } |
| 187 | |
| 188 | func TestProxy_Passthrough(t *testing.T) { |
| 189 | type route struct { |
| 190 | path, response string |
| 191 | } |
| 192 | |
| 193 | type mockedBackend struct { |
| 194 | routes []route |
| 195 | } |
| 196 | |
| 197 | type query struct { |
| 198 | path string |
| 199 | expectedRes string |
| 200 | expectedStatusCode int |
| 201 | } |
| 202 | |
| 203 | const ( |
| 204 | pathCommon = "/common" // common path implemented by both backends |
| 205 | |
| 206 | pathZero = "/zero" // only implemented by backend at index 0 |
| 207 | pathOne = "/one" // only implemented by backend at index 1 |
| 208 | |
| 209 | // responses by backend at index 0 |
| 210 | responseCommon0 = "common-0" |
| 211 | responseZero = "zero" |
| 212 | |
| 213 | // responses by backend at index 1 |
| 214 | responseCommon1 = "common-1" |
| 215 | responseOne = "one" |
| 216 | ) |
| 217 | |
| 218 | backends := []mockedBackend{ |
| 219 | { |
| 220 | routes: []route{ |
| 221 | { |
| 222 | path: pathCommon, |
| 223 | response: responseCommon0, |
| 224 | }, |
| 225 | { |
| 226 | path: pathZero, |
| 227 | response: responseZero, |
| 228 | }, |
| 229 | }, |
| 230 | }, |
| 231 | { |
| 232 | routes: []route{ |
| 233 | { |
| 234 | path: pathCommon, |
| 235 | response: responseCommon1, |
| 236 | }, |
| 237 | { |
| 238 | path: pathOne, |
| 239 | response: responseOne, |
| 240 | }, |
| 241 | }, |
| 242 | }, |
| 243 | } |
| 244 | |
| 245 | tests := map[string]struct { |