lune/tests/net/request/util.luau

27 lines
552 B
Text
Raw Permalink Normal View History

local net = require("@lune/net")
local stdio = require("@lune/stdio")
2023-01-21 06:10:19 +00:00
local util = {}
2023-02-17 14:09:30 +00:00
function util.pass(method, url, message)
2023-01-21 06:10:19 +00:00
local response = net.request({
method = method,
url = url,
})
2023-02-17 14:09:30 +00:00
if not response.ok then
error(string.format("%s failed!\nResponse: %s", message, stdio.format(response)))
end
2023-01-21 06:10:19 +00:00
end
2023-02-17 14:09:30 +00:00
function util.fail(method, url, message)
2023-01-21 06:10:19 +00:00
local response = net.request({
method = method,
url = url,
})
2023-02-17 18:20:17 +00:00
if response.ok then
2023-02-17 14:09:30 +00:00
error(string.format("%s passed!\nResponse: %s", message, stdio.format(response)))
end
2023-01-21 06:10:19 +00:00
end
return util