vtest "Stevedore variables and BYTES type test"


server s1 {
	rxreq
	txresp -bodylen 4
	rxreq
	txresp -bodylen 5
} -start

vinyl v1 -syntax 4.0 -vcl+backend {

	sub vcl_backend_response {
		set beresp.http.foo =
		    storage.Transient.used_space +
		    1 B + 1 KB + 1 MB + 1GB + 1TB;
		if (bereq.url == "/foo") {
			set beresp.storage = storage.Transient;
		}
	}
	sub vcl_deliver {
		set resp.http.bar = storage.Transient.used_space > 0B;
	}
} -start

client c1 {
	txreq
	rxresp
	expect resp.status == 200
	expect resp.http.foo == 1100586419201
	expect resp.http.bar == false

	txreq -url /foo
	rxresp
	expect resp.status == 200
	expect resp.http.foo == 1100586419201
	expect resp.http.bar == true
} -run

vinyl v1 -syntax 4.0 -errvcl {Expected BYTES unit (B, KB, MB...) got '"X"'} {
	sub vcl_recv {
		if (storage.Transient.free_space > 4 "X") {
		}
	}
}
vinyl v1 -syntax 4.0 -errvcl {Unknown BYTES unit} {
	sub vcl_recv {
		if (storage.Transient.free_space > 4 X) {
		}
	}
}
