Improve net tests

This commit is contained in:
Filip Tibell 2023-02-17 15:09:30 +01:00
parent 58ce046394
commit 744b73db3d
No known key found for this signature in database

View file

@ -1,19 +1,23 @@
local util = {}
function util.pass(method, url, message: string)
function util.pass(method, url, message)
local response = net.request({
method = method,
url = url,
})
assert(response.ok, message)
if not response.ok then
error(string.format("%s failed!\nResponse: %s", message, stdio.format(response)))
end
end
function util.fail(method, url, message: string)
function util.fail(method, url, message)
local response = net.request({
method = method,
url = url,
})
assert(not response.ok, message)
if not response.ok then
error(string.format("%s passed!\nResponse: %s", message, stdio.format(response)))
end
end
return util