(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestMap(t *testing.T) { |
| 11 | // arrange |
| 12 | tester := caddytest.NewTester(t) |
| 13 | tester.InitServer(`{ |
| 14 | skip_install_trust |
| 15 | admin localhost:2999 |
| 16 | http_port 9080 |
| 17 | https_port 9443 |
| 18 | grace_period 1ns |
| 19 | } |
| 20 | |
| 21 | localhost:9080 { |
| 22 | |
| 23 | map {http.request.method} {dest-1} {dest-2} { |
| 24 | default unknown1 unknown2 |
| 25 | ~G(.)(.) G${1}${2}-called |
| 26 | POST post-called foobar |
| 27 | } |
| 28 | |
| 29 | respond /version 200 { |
| 30 | body "hello from localhost {dest-1} {dest-2}" |
| 31 | } |
| 32 | } |
| 33 | `, "caddyfile") |
| 34 | |
| 35 | // act and assert |
| 36 | tester.AssertGetResponse("http://localhost:9080/version", 200, "hello from localhost GET-called unknown2") |
| 37 | tester.AssertPostResponseBody("http://localhost:9080/version", []string{}, bytes.NewBuffer([]byte{}), 200, "hello from localhost post-called foobar") |
| 38 | } |
| 39 | |
| 40 | func TestMapRespondWithDefault(t *testing.T) { |
| 41 | // arrange |
nothing calls this directly
no test coverage detected