diff options
| author | Stefan Boberg <[email protected]> | 2026-03-27 12:03:02 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-03-27 12:03:02 +0100 |
| commit | fa3b5090e94ee1386ca6ed6c4ddf886fa46dca54 (patch) | |
| tree | c574405fc12dd2af9fcb02353df10adb29587f6c /thirdparty/cpr/test/async_tests.cpp | |
| parent | idle deprovision in hub (#895) (diff) | |
| download | zen-fa3b5090e94ee1386ca6ed6c4ddf886fa46dca54.tar.xz zen-fa3b5090e94ee1386ca6ed6c4ddf886fa46dca54.zip | |
remove CPR HTTP client backend (#894)
CPR is no longer needed now that HttpClient has fully transitioned to raw libcurl. This removes the CPR library, its build integration, implementation files, and all conditional compilation guards, leaving curl as the sole HTTP client backend.
Diffstat (limited to 'thirdparty/cpr/test/async_tests.cpp')
| -rw-r--r-- | thirdparty/cpr/test/async_tests.cpp | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/thirdparty/cpr/test/async_tests.cpp b/thirdparty/cpr/test/async_tests.cpp deleted file mode 100644 index 026bdf0c6..000000000 --- a/thirdparty/cpr/test/async_tests.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include <gtest/gtest.h> - -#include <string> -#include <vector> - -#include <cpr/cpr.h> -#include <cpr/filesystem.h> - -#include "cpr/api.h" -#include "cpr/response.h" -#include "httpServer.hpp" - -using namespace cpr; - -static HttpServer* server = new HttpServer(); - -bool write_data(std::string /*data*/, intptr_t /*userdata*/) { - return true; -} - -TEST(AsyncTests, AsyncGetTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - cpr::AsyncResponse future = cpr::GetAsync(url); - std::string expected_text{"Hello world!"}; - cpr::Response response = future.get(); - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); -} - -TEST(AsyncTests, AsyncGetMultipleTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::vector<AsyncResponse> responses; - for (size_t i = 0; i < 10; ++i) { - responses.emplace_back(cpr::GetAsync(url)); - } - for (cpr::AsyncResponse& future : responses) { - std::string expected_text{"Hello world!"}; - cpr::Response response = future.get(); - EXPECT_EQ(expected_text, response.text); - EXPECT_EQ(url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - } -} - -TEST(AsyncTests, AsyncGetMultipleReflectTest) { - Url url{server->GetBaseUrl() + "/hello.html"}; - std::vector<AsyncResponse> responses; - for (size_t i = 0; i < 100; ++i) { - Parameters p{{"key", std::to_string(i)}}; - responses.emplace_back(cpr::GetAsync(url, p)); - } - int i = 0; - for (cpr::AsyncResponse& future : responses) { - std::string expected_text{"Hello world!"}; - cpr::Response response = future.get(); - EXPECT_EQ(expected_text, response.text); - Url expected_url{url + "?key=" + std::to_string(i)}; - EXPECT_EQ(expected_url, response.url); - EXPECT_EQ(std::string{"text/html"}, response.header["content-type"]); - EXPECT_EQ(200, response.status_code); - ++i; - } -} - -TEST(AsyncTests, AsyncDownloadTest) { - cpr::Url url{server->GetBaseUrl() + "/download_gzip.html"}; - cpr::AsyncResponse future = cpr::DownloadAsync(fs::path{"/tmp/aync_download"}, url, cpr::Header{{"Accept-Encoding", "gzip"}}, cpr::WriteCallback{write_data, 0}); - cpr::Response response = future.get(); - EXPECT_EQ(url, response.url); - EXPECT_EQ(200, response.status_code); - EXPECT_EQ(cpr::ErrorCode::OK, response.error.code); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(server); - return RUN_ALL_TESTS(); -} |