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 {
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
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.long == "fallback"
} -run
......@@ -42,6 +42,9 @@ varnish v1 -vcl+backend {
if (re2.match("", beresp.http.foo)) {
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
......@@ -55,4 +58,6 @@ client c1 {
expect resp.http.bars == "YYY"
expect resp.http.foof == "XXX"
expect resp.http.barf == "YYY"
expect resp.http.barsub == "YYYXXX"
expect resp.http.barsubf == "YYYXXX"
} -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