Commit 67216fc2 authored by Geoff Simmons's avatar Geoff Simmons

add tests for the sub() method and function to vtc's adapted from

Varnish regression tests
parent 5698333d
...@@ -30,10 +30,17 @@ varnish v1 -vcl+backend { ...@@ -30,10 +30,17 @@ varnish v1 -vcl+backend {
return(synth(500, "not ok")); return(synth(500, "not ok"));
} }
} }
sub vcl_deliver {
set resp.http.long
= re2.sub("^(abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij|abcdefghij)",
req.http.host, "z", "fallback");
}
} -start } -start
client c1 { client c1 {
txreq txreq
rxresp rxresp
expect resp.status == 200 expect resp.status == 200
expect resp.http.long == "fallback"
} -run } -run
...@@ -42,6 +42,9 @@ varnish v1 -vcl+backend { ...@@ -42,6 +42,9 @@ varnish v1 -vcl+backend {
if (re2.match("", beresp.http.foo)) { if (re2.match("", beresp.http.foo)) {
set beresp.http.barf = "YYY"; set beresp.http.barf = "YYY";
} }
# Tests for sub() with regex "$" are in sub.vtc
set beresp.http.barsub = empty.sub(beresp.http.foo, "YYY");
set beresp.http.barsubf = re2.sub("", beresp.http.foo, "YYY");
} }
} -start } -start
...@@ -55,4 +58,6 @@ client c1 { ...@@ -55,4 +58,6 @@ client c1 {
expect resp.http.bars == "YYY" expect resp.http.bars == "YYY"
expect resp.http.foof == "XXX" expect resp.http.foof == "XXX"
expect resp.http.barf == "YYY" expect resp.http.barf == "YYY"
expect resp.http.barsub == "YYYXXX"
expect resp.http.barsubf == "YYYXXX"
} -run } -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment