From 65ea0edc12a3e27aec75c9d6f4449e826440f7d8 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Wed, 24 May 2023 11:25:14 +0200 Subject: [PATCH] Migrate away from httpbin for unit tests --- tests/net/request/codes.luau | 6 +++--- tests/net/request/methods.luau | 10 +++++----- tests/net/request/query.luau | 9 ++++++--- tests/net/request/redirect.luau | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/net/request/codes.luau b/tests/net/request/codes.luau index c454608..9b7e7d0 100644 --- a/tests/net/request/codes.luau +++ b/tests/net/request/codes.luau @@ -1,6 +1,6 @@ local util = require("./util") local pass, fail = util.pass, util.fail -pass("GET", "https://httpbin.org/status/200", "Request status code - 200") -fail("GET", "https://httpbin.org/status/400", "Request status code - 400") -fail("GET", "https://httpbin.org/status/500", "Request status code - 500") +pass("GET", "https://httpbingo.org/status/200", "Request status code - 200") +fail("GET", "https://httpbingo.org/status/400", "Request status code - 400") +fail("GET", "https://httpbingo.org/status/500", "Request status code - 500") diff --git a/tests/net/request/methods.luau b/tests/net/request/methods.luau index beed786..6635d77 100644 --- a/tests/net/request/methods.luau +++ b/tests/net/request/methods.luau @@ -2,8 +2,8 @@ local util = require("./util") local pass = util.pass -- stylua: ignore start -pass("GET", "https://httpbin.org/get", "Request method - GET") -pass("POST", "https://httpbin.org/post", "Request method - POST") -pass("PATCH", "https://httpbin.org/patch", "Request method - PATCH") -pass("PUT", "https://httpbin.org/put", "Request method - PUT") -pass("DELETE", "https://httpbin.org/delete", "Request method - DELETE") +pass("GET", "https://httpbingo.org/get", "Request method - GET") +pass("POST", "https://httpbingo.org/post", "Request method - POST") +pass("PATCH", "https://httpbingo.org/patch", "Request method - PATCH") +pass("PUT", "https://httpbingo.org/put", "Request method - PUT") +pass("DELETE", "https://httpbingo.org/delete", "Request method - DELETE") diff --git a/tests/net/request/query.luau b/tests/net/request/query.luau index 6048caf..d0d55ba 100644 --- a/tests/net/request/query.luau +++ b/tests/net/request/query.luau @@ -10,7 +10,7 @@ local QUERY: { [string]: string } = { -- as a special non-ascii one that needs url encoding local response = net.request({ - url = "https://httpbin.org/anything", + url = "https://httpbingo.org/anything", query = QUERY, }) @@ -30,10 +30,13 @@ assert(success, "Failed to decode json response\n" .. tostring(json)) local args = if type(json.args) == "table" then json.args else nil assert(args ~= nil, "Response body did not contain an args table") --- The args table should then have the *exact* same contents as our query +-- The args table should then have the same contents as our query, +-- these will however be returned as arrays of strings and not a +-- single string, presumably because http query params support +-- multiple values of the same name, so we just grab the first for key, value in QUERY do - local received = args[key] + local received = args[key][1] if received == nil then error(string.format("Response body did not contain query parameter '%s'", key)) elseif typeof(received) ~= typeof(value) then diff --git a/tests/net/request/redirect.luau b/tests/net/request/redirect.luau index d8b235f..859eadf 100644 --- a/tests/net/request/redirect.luau +++ b/tests/net/request/redirect.luau @@ -1,4 +1,4 @@ local util = require("./util") local pass = util.pass -pass("GET", "https://httpbin.org/absolute-redirect/3", "Redirect 3 times") +pass("GET", "https://httpbingo.org/absolute-redirect/3", "Redirect 3 times")