Skip to content

Commit dc76dac

Browse files
committed
Fixed build for older compilers + more detailed tests
1 parent ece5e9b commit dc76dac

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

ut/client_ut.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@
1212

1313
#include <memory>
1414
#include <optional>
15+
#include <ostream>
1516
#include <string_view>
1617
#include <thread>
1718
#include <chrono>
1819

1920
using namespace clickhouse;
2021

22+
namespace clickhouse {
23+
std::ostream & operator << (std::ostream & ostr, const Endpoint & endpoint) {
24+
return ostr << endpoint.host << ":" << endpoint.port;
25+
}
26+
}
2127

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

1434-
const auto endpoints = {
1440+
const std::vector<Endpoint> endpoints = {
14351441
Endpoint{"foo-invalid-hostname", 1234},
14361442
Endpoint{"bar-invalid-hostname", 4567},
14371443
};
@@ -1444,4 +1450,14 @@ TEST(SimpleClientTest, issue_335_reconnects_count) {
14441450
);
14451451

14461452
EXPECT_EQ(endpoints.size(), connect_requests.size());
1453+
// make sure there was an attempt to connect to each endpoint at least once.
1454+
for (const auto & endpoint : endpoints)
1455+
{
1456+
auto p = std::find_if(connect_requests.begin(), connect_requests.end(), [&endpoint](const auto & connect_request) {
1457+
return connect_request.second == endpoint;
1458+
});
1459+
1460+
EXPECT_TRUE(connect_requests.end() != p)
1461+
<< "\tThere was no attempt to connect to endpoint " << endpoint;
1462+
}
14471463
}

0 commit comments

Comments
 (0)