2023-05-14 21:16:58 +01:00
|
|
|
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
|