Skip to content

Commit 8bc31b0

Browse files
cyfdecyfartpaul
authored andcommitted
Port simple test examples to Google Test. (ClickHouse#41)
* Port simple test examples to Google Test. * Install clickhouse for travis. * Fix clang compile error.
1 parent 22075e5 commit 8bc31b0

File tree

6 files changed

+399
-1
lines changed

6 files changed

+399
-1
lines changed

.travis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@ matrix:
1717
osx_image: xcode8.2
1818
compiler: clang
1919

20+
before_install:
21+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo 'deb http://repo.yandex.ru/clickhouse/trusty stable main' | sudo tee /etc/apt/sources.list.d/clickhouse.list ; fi
22+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E0C56BD4 ; fi
23+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -q && sudo apt-get install -q -y clickhouse-server-common ; fi
24+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo service clickhouse-server start ; fi
25+
2026
# Build steps
2127
script:
2228
- mkdir build
2329
- cd build
24-
- cmake .. && make && ./ut/clickhouse-cpp-ut
30+
- cmake .. && make
31+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./ut/clickhouse-cpp-ut ; fi
32+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./ut/clickhouse-cpp-ut --gtest_filter='-Client/*' ; fi

clickhouse/block.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ class Block {
5454
/// Count of rows in the block.
5555
size_t GetRowCount() const;
5656

57+
const std::string& GetColumnName(size_t idx) const {
58+
return columns_.at(idx).name;
59+
}
60+
5761
/// Reference to column by index in the block.
5862
ColumnRef operator [] (size_t idx) const;
5963

clickhouse/client.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ struct ServerInfo {
5454
uint64_t revision;
5555
};
5656

57+
std::ostream& operator<<(std::ostream& os, const ClientOptions& opt) {
58+
os << "Client(" << opt.user << '@' << opt.host << ":" << opt.port
59+
<< " ping_before_query:" << opt.ping_before_query
60+
<< " send_retries:" << opt.send_retries
61+
<< " retry_timeout:" << opt.retry_timeout.count()
62+
<< " compression_method:"
63+
<< (opt.compression_method == CompressionMethod::LZ4 ? "LZ4" : "None")
64+
<< ")";
65+
return os;
66+
}
5767

5868
class Client::Impl {
5969
public:

clickhouse/client.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <chrono>
1616
#include <memory>
17+
#include <ostream>
1718
#include <string>
1819

1920
namespace clickhouse {
@@ -62,6 +63,8 @@ struct ClientOptions {
6263
#undef DECLARE_FIELD
6364
};
6465

66+
std::ostream& operator<<(std::ostream& os, const ClientOptions& options);
67+
6568
/**
6669
*
6770
*/

ut/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ADD_EXECUTABLE (clickhouse-cpp-ut
44
columns_ut.cpp
55
types_ut.cpp
66
type_parser_ut.cpp
7+
client_ut.cpp
78
)
89

910
TARGET_LINK_LIBRARIES (clickhouse-cpp-ut

0 commit comments

Comments
 (0)