Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ add_library(alternator_client_cpp
add_library(ScyllaDB::alternator_client_cpp ALIAS alternator_client_cpp)

target_compile_features(alternator_client_cpp PUBLIC cxx_std_17)
target_compile_definitions(alternator_client_cpp
PUBLIC
SCYLLADB_ALTERNATOR_CLIENT_CPP_VERSION="${PROJECT_VERSION}")
target_include_directories(alternator_client_cpp
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Expand Down Expand Up @@ -106,6 +109,7 @@ if(ALTERNATOR_CLIENT_CPP_BUILD_TESTS)

set(ALTERNATOR_CLIENT_CPP_CORE_TEST_SOURCES
tests/attribute_value_test.cpp
tests/config_test.cpp
tests/header_optimization_test.cpp
tests/http_client_test.cpp
tests/key_route_affinity_test.cpp
Expand Down
6 changes: 5 additions & 1 deletion include/scylladb/alternator/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include <scylladb/alternator/node_health.h>
#include <scylladb/alternator/routing_scope.h>

#ifndef SCYLLADB_ALTERNATOR_CLIENT_CPP_VERSION
#define SCYLLADB_ALTERNATOR_CLIENT_CPP_VERSION "devel"
#endif

namespace scylladb::alternator {

struct Credentials {
Expand Down Expand Up @@ -88,7 +92,7 @@ struct Config {
unsigned max_connections = 100;
bool reuse_discovery_connections = true;
std::vector<std::shared_ptr<HttpContentEncodingDecoder>> content_encoding_decoders;
std::string user_agent = "scylladb-alternator-client-cpp/devel";
std::string user_agent = "scylladb-alternator-client-cpp/" SCYLLADB_ALTERNATOR_CLIENT_CPP_VERSION;
std::shared_ptr<HeaderOptimization> header_optimization;

NodeHealthStoreConfig node_health;
Expand Down
24 changes: 24 additions & 0 deletions tests/config_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <scylladb/alternator/config.h>

#include <gtest/gtest.h>

#include <string>

using namespace scylladb::alternator;

TEST(Config, DefaultUserAgentUsesProjectVersion) {
const Config config;

EXPECT_EQ(
config.user_agent,
std::string("scylladb-alternator-client-cpp/") + SCYLLADB_ALTERNATOR_CLIENT_CPP_VERSION);
EXPECT_NE(config.user_agent, "scylladb-alternator-client-cpp/devel");
}

TEST(Config, UserAgentCanBeCleared) {
Config config;

config.user_agent.clear();

EXPECT_TRUE(config.user_agent.empty());
}
Loading