test.lua revision c381599e85eb318a270f3e3b07851bff77e5c151
--
--
local mu =
require "moonunit" local http =
require "helpers"
assert(200 == c, "expected status code 200, got " .. c) assert(b:find("test"), "test not found in document root") end
assert(200 == c, "expected status code 200, got " .. c) assert(b:find("hello Lua world"), "'hello Lua world' not found in response") end
assert(200 == c, "unexpected response code " .. c) assert(b == 'hello!', "unexpected response body [" .. b .. "]") end
local b, c =
http.post "/basic" "hello=7&hello=1" assert(200 == c, "expected status code 200, got " .. c) assert(b:find("complex:%s+hello: 7, 1\n"), "didn't find complex post parsing") assert(b:find("simple:%s+hello: 7\n"), "didn't find simple post parsing") end
local b, c =
http.post("/test_foo", "hello=7&hello=1") assert(201 == c, "expected status code 200, got " .. c) assert(b:find("Handler FOO!"), "unexpected output!") end
assert(200 == c, "expected status code 200, got " .. c) assert(b:find("hello: 7"), "didn't get expected post data [" .. b .."]")
assert(200 == c, "expected status code 200, got " .. c) assert(b:find("hello: 7"), "didn't get expected post data [" .. b .."]") assert(b:find("goodbye: 8"), "didn't get expected post data [" .. b .."]") end
assert(200 == c, "expected status code 200, got " .. c) end
local r, c = http.get "/test_attributes?yes=no" assert(201 == c, "expected status code 201, got " .. c)
assert(r:find("status: 200\nstatus: 201"), "changing status code failed") assert(r:find("method: GET"), "method wasn't reported correctly") assert(r:find("protocol: HTTP/1.1"), "protocol reported incorrectly") assert(r:find("assbackwards: false"), "assbackwards reported incorrectly") assert(r:find("args: yes=no"), "args not reported correctly") end
assert(200 == c, "expected status code 200, got " .. c) assert(r:find("matched in handle_regex"), "didn't find 'matched in handle_regex'") end
assert(200 == c, "expected status code 200, got " .. c) assert(r:find("matched in handle_regex"), "didn't find 'matched in handle_regex'") end
assert(200 == c, "expected 200 got " .. c) assert(r:find("please find me"), "didn't get expected static file :-(, instead got " .. r) end
local r, c = http.get "/translate-name2" assert(200 == c, "expected 200 got " .. c) assert(r:find("please find me"), "didn't get expected static file :-(, instead got " .. r) end
local r, c = http.get "/test_serverversion" assert(r:find("Apache/2"), "version isn't Apache/2, but is " .. r) end
local r, c = http.get "/test_fixupstest" assert(201 == c, "incorrect status code returned, expected 201 got " .. c) assert(r:find("status is 201"), "handler sees incorrect status") end
assert(200 == c, "incorrect status code returned, expected 200 got " .. c) end