2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00
koreader/spec/unit/httpclient_spec.lua
NiLuJe 62059f8d68
Misc: Get rid of the legacy defaults.lua globals (#9546)
* This removes support for the following deprecated constants: `DTAP_ZONE_FLIPPING`, `DTAP_ZONE_BOOKMARK`, `DCREREADER_CONFIG_DEFAULT_FONT_GAMMA`
* The "Advanced settings" panel now highlights modified values in bold (think about:config in Firefox ;)).
* LuaData: Isolate global table lookup shenanigans, and fix a few issues in unused-in-prod codepaths.
* CodeStyle: Require module locals for Lua/C modules, too.
* ScreenSaver: Actually garbage collect our widget on close (ScreenSaver itself is not an instantiated object).
* DateTimeWidget: Code cleanups to ensure child widgets can be GC'ed.
2022-09-28 01:10:50 +02:00

41 lines
1.2 KiB
Lua

describe("HTTP client module #notest #nocov", function()
local UIManager
setup(function()
require("commonrequire")
UIManager = require("ui/uimanager")
-- Set true to test httpclient
G_defaults:makeFalse("DUSE_TURBO_LIB")
end)
teardown(function()
G_defaults:delSetting("DUSE_TURBO_LIB")
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
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",
"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)