1
0
mirror of synced 2024-11-24 15:50:16 +01:00
ImHex/tests/helpers/source/net.cpp

54 lines
1.2 KiB
C++
Raw Normal View History

#include <hex/test/tests.hpp>
2023-04-19 21:56:34 +02:00
#include <hex/api_urls.hpp>
#include <hex/helpers/http_requests.hpp>
2023-03-13 09:25:07 +01:00
#include <wolv/io/file.hpp>
using namespace std::literals::string_literals;
TEST_SEQUENCE("StoreAPI") {
hex::HttpRequest request("GET", ImHexApiURL + "/store"s);
auto result = request.execute().get();
if (result.getStatusCode() != 200)
TEST_FAIL();
if (result.getData().empty())
TEST_FAIL();
TEST_SUCCESS();
};
TEST_SEQUENCE("TipsAPI") {
hex::HttpRequest request("GET", ImHexApiURL + "/tip"s);
auto result = request.execute().get();
if (result.getStatusCode() != 200)
TEST_FAIL();
if (result.getData().empty())
TEST_FAIL();
TEST_SUCCESS();
};
TEST_SEQUENCE("ContentAPI") {
hex::HttpRequest request("GET", "https://api.werwolv.net/content/imhex/patterns/elf.hexpat");
2022-03-04 14:34:37 +01:00
const auto FilePath = std::fs::current_path() / "elf.hexpat";
auto result = request.downloadFile(FilePath).get();
TEST_ASSERT(result.getStatusCode() == 200);
2023-03-13 09:25:07 +01:00
wolv::io::File file(FilePath, wolv::io::File::Mode::Read);
if (!file.isValid())
TEST_FAIL();
if (file.getSize() == 0)
TEST_FAIL();
TEST_SUCCESS();
};