2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00
koreader/spec/unit/httpclient_spec.lua

39 lines
1.1 KiB
Lua
Raw Normal View History

2015-09-12 19:28:17 +00:00
-- set true to test httpclient
DUSE_TURBO_LIB = false
describe("HTTP client module #notest #nocov", function()
2017-01-21 13:58:01 +00:00
local UIManager
setup(function()
require("commonrequire")
UIManager = require("ui/uimanager")
end)
local requests = 0
local function response_callback(res)
requests = requests - 1
if requests == 0 then UIManager:quit() end
assert(not res.error, "error occurs")
assert(res.body)
end
2017-01-21 13:58:01 +00:00
it("should get response from async GET request", function()
local HTTPClient = require("httpclient")
local async_client = HTTPClient:new()
UIManager:quit()
local urls = {
"http://www.example.com",
"http://www.example.org",
2015-04-28 03:06:00 +00:00
"http://www.example.net",
"https://www.example.com",
"https://www.example.org",
}
requests = #urls
for _, url in ipairs(urls) do
async_client:request({
url = url,
}, response_callback)
end
UIManager:runForever()
end)
end)