Skip to content

Commit

Permalink
Fixed build for older compilers + more detailed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Enmk committed Sep 30, 2023
1 parent ece5e9b commit dc76dac
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion ut/client_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@

#include <memory>
#include <optional>
#include <ostream>
#include <string_view>
#include <thread>
#include <chrono>

using namespace clickhouse;

namespace clickhouse {
std::ostream & operator << (std::ostream & ostr, const Endpoint & endpoint) {
return ostr << endpoint.host << ":" << endpoint.port;
}
}

template <typename T>
std::shared_ptr<T> createTableWithOneColumn(Client & client, const std::string & table_name, const std::string & column_name)
Expand Down Expand Up @@ -1431,7 +1437,7 @@ TEST(SimpleClientTest, issue_335_reconnects_count) {
std::unique_ptr<SocketFactory> wrapped_socket_factory = std::make_unique<NonSecureSocketFactory>();
std::unique_ptr<SocketFactory> socket_factory = std::make_unique<CountingSocketFactoryAdapter>(*wrapped_socket_factory, connect_requests);

const auto endpoints = {
const std::vector<Endpoint> endpoints = {
Endpoint{"foo-invalid-hostname", 1234},
Endpoint{"bar-invalid-hostname", 4567},
};
Expand All @@ -1444,4 +1450,14 @@ TEST(SimpleClientTest, issue_335_reconnects_count) {
);

EXPECT_EQ(endpoints.size(), connect_requests.size());
// make sure there was an attempt to connect to each endpoint at least once.
for (const auto & endpoint : endpoints)
{
auto p = std::find_if(connect_requests.begin(), connect_requests.end(), [&endpoint](const auto & connect_request) {
return connect_request.second == endpoint;
});

EXPECT_TRUE(connect_requests.end() != p)
<< "\tThere was no attempt to connect to endpoint " << endpoint;
}
}

0 comments on commit dc76dac

Please sign in to comment.