diff options
Diffstat (limited to 'test/httptest.lua')
-rw-r--r-- | test/httptest.lua | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/test/httptest.lua b/test/httptest.lua index 1eb4b6a..030974c 100644 --- a/test/httptest.lua +++ b/test/httptest.lua | |||
@@ -3,9 +3,6 @@ | |||
3 | -- needs ScriptAlias from /home/c/diego/tec/luasocket/test/cgi | 3 | -- needs ScriptAlias from /home/c/diego/tec/luasocket/test/cgi |
4 | -- to /luasocket-test-cgi | 4 | -- to /luasocket-test-cgi |
5 | -- needs AllowOverride AuthConfig on /home/c/diego/tec/luasocket/test/auth | 5 | -- needs AllowOverride AuthConfig on /home/c/diego/tec/luasocket/test/auth |
6 | |||
7 | dofile("noglobals.lua") | ||
8 | |||
9 | local similar = function(s1, s2) | 6 | local similar = function(s1, s2) |
10 | return string.lower(string.gsub(s1 or "", "%s", "")) == | 7 | return string.lower(string.gsub(s1 or "", "%s", "")) == |
11 | string.lower(string.gsub(s2 or "", "%s", "")) | 8 | string.lower(string.gsub(s2 or "", "%s", "")) |
@@ -27,27 +24,27 @@ end | |||
27 | 24 | ||
28 | local check = function (v, e) | 25 | local check = function (v, e) |
29 | if v then print("ok") | 26 | if v then print("ok") |
30 | else %fail(e) end | 27 | else fail(e) end |
31 | end | 28 | end |
32 | 29 | ||
33 | local check_request = function(request, expect, ignore) | 30 | local check_request = function(request, expect, ignore) |
34 | local response = socket.http.request(request) | 31 | local response = socket.http.request(request) |
35 | for i,v in response do | 32 | for i,v in response do |
36 | if not ignore[i] then | 33 | if not ignore[i] then |
37 | if v ~= expect[i] then %fail(i .. " differs!") end | 34 | if v ~= expect[i] then fail(i .. " differs!") end |
38 | end | 35 | end |
39 | end | 36 | end |
40 | for i,v in expect do | 37 | for i,v in expect do |
41 | if not ignore[i] then | 38 | if not ignore[i] then |
42 | if v ~= response[i] then %fail(i .. " differs!") end | 39 | if v ~= response[i] then fail(i .. " differs!") end |
43 | end | 40 | end |
44 | end | 41 | end |
45 | print("ok") | 42 | print("ok") |
46 | end | 43 | end |
47 | 44 | ||
48 | local request, response, ignore, expect, index, prefix, cgiprefix | 45 | local host, request, response, ignore, expect, index, prefix, cgiprefix |
49 | 46 | ||
50 | local t = socket._time() | 47 | local t = socket.time() |
51 | 48 | ||
52 | host = host or "localhost" | 49 | host = host or "localhost" |
53 | prefix = prefix or "/luasocket" | 50 | prefix = prefix or "/luasocket" |
@@ -310,4 +307,4 @@ check(response and response.headers) | |||
310 | 307 | ||
311 | print("passed all tests") | 308 | print("passed all tests") |
312 | 309 | ||
313 | print(string.format("done in %.2fs", socket._time() - t)) | 310 | print(string.format("done in %.2fs", socket.time() - t)) |