MCPcopy
hub / github.com/caddyserver/caddy / TestMap

Function TestMap

caddytest/integration/map_test.go:10–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func 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
40func TestMapRespondWithDefault(t *testing.T) {
41 // arrange

Callers

nothing calls this directly

Calls 4

InitServerMethod · 0.95
AssertGetResponseMethod · 0.95
NewTesterFunction · 0.92

Tested by

no test coverage detected