Skip to content
Snippets Groups Projects
Commit c70ce336 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

MAINT: rename get_env_var to get_env_fallback

parent c10ce9ce
No related branches found
No related tags found
No related merge requests found
Pipeline #12584 passed
...@@ -32,17 +32,15 @@ ...@@ -32,17 +32,15 @@
* @date 2021-07-07 * @date 2021-07-07
*/ */
#define EXPECT_THROW_MESSAGE(statement, exeption_type, message) \ #define EXPECT_THROW_MESSAGE(statement, exeption_type, message) \
EXPECT_THROW( \ EXPECT_THROW(try { statement; } catch (const exeption_type &e) { \
try { statement; } catch (const exeption_type &e) { \ EXPECT_EQ(std::string(e.what()), message); \
EXPECT_EQ(std::string(e.what()), message); \ throw; \
throw; \ }, \
}, \ exeption_type)
exeption_type)
#define ASSERT_THROW_MESSAGE(statement, exeption_type, message) \ #define ASSERT_THROW_MESSAGE(statement, exeption_type, message) \
ASSERT_THROW( \ ASSERT_THROW(try { statement; } catch (const exeption_type &e) { \
try { statement; } catch (const exeption_type &e) { \ ASSERT_EQ(std::string(e.what()), message); \
ASSERT_EQ(std::string(e.what()), message); \ throw; \
throw; \ }, \
}, \ exeption_type)
exeption_type)
#endif #endif
...@@ -356,7 +356,7 @@ TEST_F(test_ccaosdb, test_insert_update_delete) { ...@@ -356,7 +356,7 @@ TEST_F(test_ccaosdb, test_insert_update_delete) {
// Change name and update // Change name and update
return_code = return_code =
caosdb_entity_entity_set_name(&retrieved_entity_1, "TestNameNew"); caosdb_entity_entity_set_name(&retrieved_entity_1, "TestNameNew");
EXPECT_EQ(return_code, 0); EXPECT_EQ(return_code, 0);
caosdb_transaction_transaction update_transaction; caosdb_transaction_transaction update_transaction;
caosdb_connection_connection_create_transaction(&connection, caosdb_connection_connection_create_transaction(&connection,
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "caosdb/constants.h" // for COMPATIBLE_SERVER_VERSION_M... #include "caosdb/constants.h" // for COMPATIBLE_SERVER_VERSION_M...
#include "caosdb/exceptions.h" // for AuthenticationError, Connec... #include "caosdb/exceptions.h" // for AuthenticationError, Connec...
#include "caosdb/info.h" // for VersionInfo #include "caosdb/info.h" // for VersionInfo
#include "caosdb/utility.h" // for get_env_var #include "caosdb/utility.h" // for get_env_fallback
#include "caosdb_test_utility.h" // for EXPECT_THROW_MESSAGE #include "caosdb_test_utility.h" // for EXPECT_THROW_MESSAGE
#include "gtest/gtest_pred_impl.h" // NOLINT TODO how to fix this? for Test, TestInfo, TEST, EXPEC... #include "gtest/gtest_pred_impl.h" // NOLINT TODO how to fix this? for Test, TestInfo, TEST, EXPEC...
#include <gtest/gtest-message.h> // for Message #include <gtest/gtest-message.h> // for Message
...@@ -62,10 +62,10 @@ TEST(test_connection, connect_somehost_42347_fails) { ...@@ -62,10 +62,10 @@ TEST(test_connection, connect_somehost_42347_fails) {
TEST(test_connection, connection_insecure_authentication_error_anonymous) { TEST(test_connection, connection_insecure_authentication_error_anonymous) {
const auto *port_str = const auto *port_str =
caosdb::utility::get_env_var("CAOSDB_SERVER_GRPC_PORT_HTTP", "8080"); caosdb::utility::get_env_fallback("CAOSDB_SERVER_GRPC_PORT_HTTP", "8080");
auto port = std::stoi(port_str); auto port = std::stoi(port_str);
const auto *const host = const auto *const host =
caosdb::utility::get_env_var("CAOSDB_SERVER_HOST", "localhost"); caosdb::utility::get_env_fallback("CAOSDB_SERVER_HOST", "localhost");
auto config = InsecureConnectionConfiguration(host, port); auto config = InsecureConnectionConfiguration(host, port);
auto connection = Connection(config); auto connection = Connection(config);
...@@ -75,12 +75,12 @@ TEST(test_connection, connection_insecure_authentication_error_anonymous) { ...@@ -75,12 +75,12 @@ TEST(test_connection, connection_insecure_authentication_error_anonymous) {
TEST(test_connection, connection_ssl_authentication_error_anonymous) { TEST(test_connection, connection_ssl_authentication_error_anonymous) {
const auto *port_str = const auto *port_str =
caosdb::utility::get_env_var("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443"); caosdb::utility::get_env_fallback("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443");
auto port = std::stoi(port_str); auto port = std::stoi(port_str);
const auto *const host = const auto *const host =
caosdb::utility::get_env_var("CAOSDB_SERVER_HOST", "localhost"); caosdb::utility::get_env_fallback("CAOSDB_SERVER_HOST", "localhost");
const auto path = const auto path =
caosdb::utility::get_env_var("CAOSDB_SERVER_CERT", std::string()); caosdb::utility::get_env_fallback("CAOSDB_SERVER_CERT", std::string());
auto cert = PemFileCertificateProvider(path); auto cert = PemFileCertificateProvider(path);
auto config = TlsConnectionConfiguration(host, port, cert); auto config = TlsConnectionConfiguration(host, port, cert);
...@@ -94,12 +94,12 @@ TEST(test_connection, connection_ssl_authentication_error_anonymous) { ...@@ -94,12 +94,12 @@ TEST(test_connection, connection_ssl_authentication_error_anonymous) {
TEST(test_connection, connection_ssl_authentication_error_wrong_credentials) { TEST(test_connection, connection_ssl_authentication_error_wrong_credentials) {
const auto *port_str = const auto *port_str =
caosdb::utility::get_env_var("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443"); caosdb::utility::get_env_fallback("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443");
auto port = std::stoi(port_str); auto port = std::stoi(port_str);
const auto *const host = const auto *const host =
caosdb::utility::get_env_var("CAOSDB_SERVER_HOST", "localhost"); caosdb::utility::get_env_fallback("CAOSDB_SERVER_HOST", "localhost");
const auto path = const auto path =
caosdb::utility::get_env_var("CAOSDB_SERVER_CERT", std::string()); caosdb::utility::get_env_fallback("CAOSDB_SERVER_CERT", std::string());
const auto *const user = "not-a-user-23461237"; const auto *const user = "not-a-user-23461237";
const auto *const password = "very-c-cred"; const auto *const password = "very-c-cred";
......
...@@ -812,7 +812,7 @@ TEST_F(test_transaction, test_file_up_n_download) { ...@@ -812,7 +812,7 @@ TEST_F(test_transaction, test_file_up_n_download) {
auto download_transaction(connection->CreateTransaction()); auto download_transaction(connection->CreateTransaction());
download_transaction->RetrieveAndDownloadFileById( download_transaction->RetrieveAndDownloadFileById(
inserted_file.GetId(), test_download_file_1.string()); inserted_file.GetId(), test_download_file_1.string());
download_transaction->ExecuteAsynchronously(); download_transaction->ExecuteAsynchronously();
ASSERT_EQ(download_transaction->WaitForIt().GetCode(), StatusCode::SUCCESS); ASSERT_EQ(download_transaction->WaitForIt().GetCode(), StatusCode::SUCCESS);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment