summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/map/map_test.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2022-03-21 17:05:38 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2022-03-21 17:05:38 -0600
commit55b4c12e0404347828ed691594d1f8ae8228c598 (patch)
treefc3e05aaea19dafcb339eb7a9d32efcc431ae491 /modules/caddyhttp/map/map_test.go
parent2196c92c0ef4e3d3622d5a8bb549e5faed135382 (diff)
map: Evaluate placeholders in output vals (#4650)
Diffstat (limited to 'modules/caddyhttp/map/map_test.go')
-rw-r--r--modules/caddyhttp/map/map_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/caddyhttp/map/map_test.go b/modules/caddyhttp/map/map_test.go
index 2789459..26d6e85 100644
--- a/modules/caddyhttp/map/map_test.go
+++ b/modules/caddyhttp/map/map_test.go
@@ -82,6 +82,22 @@ func TestHandler(t *testing.T) {
"output": "3",
},
},
+ {
+ reqURI: "/foo",
+ handler: Handler{
+ Source: "{http.request.uri.path}",
+ Destinations: []string{"{output}"},
+ Mappings: []Mapping{
+ {
+ Input: "/foo",
+ Outputs: []interface{}{"{testvar}"},
+ },
+ },
+ },
+ expect: map[string]interface{}{
+ "output": "testing",
+ },
+ },
} {
if err := tc.handler.Provision(caddy.Context{}); err != nil {
t.Fatalf("Test %d: Provisioning handler: %v", i, err)
@@ -92,6 +108,7 @@ func TestHandler(t *testing.T) {
t.Fatalf("Test %d: Creating request: %v", i, err)
}
repl := caddyhttp.NewTestReplacer(req)
+ repl.Set("testvar", "testing")
ctx := context.WithValue(req.Context(), caddy.ReplacerCtxKey, repl)
req = req.WithContext(ctx)