From c70ce3369e83ff575e1f477cb782b89a1e1a7fab Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Wed, 25 Aug 2021 15:17:05 +0200
Subject: [PATCH] MAINT: rename get_env_var to get_env_fallback

---
 test/caosdb_test_utility.h | 22 ++++++++++------------
 test/test_ccaosdb.cpp      |  2 +-
 test/test_connection.cpp   | 18 +++++++++---------
 test/test_transaction.cpp  |  2 +-
 4 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/test/caosdb_test_utility.h b/test/caosdb_test_utility.h
index 4cde3dc..cd1b47c 100644
--- a/test/caosdb_test_utility.h
+++ b/test/caosdb_test_utility.h
@@ -32,17 +32,15 @@
  * @date 2021-07-07
  */
 #define EXPECT_THROW_MESSAGE(statement, exeption_type, message)                \
-  EXPECT_THROW(                                                                \
-      try { statement; } catch (const exeption_type &e) {                      \
-        EXPECT_EQ(std::string(e.what()), message);                             \
-        throw;                                                                 \
-      },                                                                       \
-      exeption_type)
+  EXPECT_THROW(try { statement; } catch (const exeption_type &e) {             \
+    EXPECT_EQ(std::string(e.what()), message);                                 \
+    throw;                                                                     \
+  },                                                                           \
+               exeption_type)
 #define ASSERT_THROW_MESSAGE(statement, exeption_type, message)                \
-  ASSERT_THROW(                                                                \
-      try { statement; } catch (const exeption_type &e) {                      \
-        ASSERT_EQ(std::string(e.what()), message);                             \
-        throw;                                                                 \
-      },                                                                       \
-      exeption_type)
+  ASSERT_THROW(try { statement; } catch (const exeption_type &e) {             \
+    ASSERT_EQ(std::string(e.what()), message);                                 \
+    throw;                                                                     \
+  },                                                                           \
+               exeption_type)
 #endif
diff --git a/test/test_ccaosdb.cpp b/test/test_ccaosdb.cpp
index e10626b..a9b023c 100644
--- a/test/test_ccaosdb.cpp
+++ b/test/test_ccaosdb.cpp
@@ -356,7 +356,7 @@ TEST_F(test_ccaosdb, test_insert_update_delete) {
 
   // Change name and update
   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);
   caosdb_transaction_transaction update_transaction;
   caosdb_connection_connection_create_transaction(&connection,
diff --git a/test/test_connection.cpp b/test/test_connection.cpp
index 6f27f23..01dcc71 100644
--- a/test/test_connection.cpp
+++ b/test/test_connection.cpp
@@ -26,7 +26,7 @@
 #include "caosdb/constants.h"            // for COMPATIBLE_SERVER_VERSION_M...
 #include "caosdb/exceptions.h"           // for AuthenticationError, Connec...
 #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 "gtest/gtest_pred_impl.h" // NOLINT TODO how to fix this? for Test, TestInfo, TEST, EXPEC...
 #include <gtest/gtest-message.h>   // for Message
@@ -62,10 +62,10 @@ TEST(test_connection, connect_somehost_42347_fails) {
 
 TEST(test_connection, connection_insecure_authentication_error_anonymous) {
   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);
   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 connection = Connection(config);
@@ -75,12 +75,12 @@ TEST(test_connection, connection_insecure_authentication_error_anonymous) {
 
 TEST(test_connection, connection_ssl_authentication_error_anonymous) {
   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);
   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 =
-      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 config = TlsConnectionConfiguration(host, port, cert);
@@ -94,12 +94,12 @@ TEST(test_connection, connection_ssl_authentication_error_anonymous) {
 
 TEST(test_connection, connection_ssl_authentication_error_wrong_credentials) {
   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);
   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 =
-      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 password = "very-c-cred";
 
diff --git a/test/test_transaction.cpp b/test/test_transaction.cpp
index 1ba10ac..ce4632d 100644
--- a/test/test_transaction.cpp
+++ b/test/test_transaction.cpp
@@ -812,7 +812,7 @@ TEST_F(test_transaction, test_file_up_n_download) {
 
   auto download_transaction(connection->CreateTransaction());
   download_transaction->RetrieveAndDownloadFileById(
-    inserted_file.GetId(), test_download_file_1.string());
+      inserted_file.GetId(), test_download_file_1.string());
   download_transaction->ExecuteAsynchronously();
   ASSERT_EQ(download_transaction->WaitForIt().GetCode(), StatusCode::SUCCESS);
 
-- 
GitLab