Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cpplib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Commits
13b955a1
Commit
13b955a1
authored
3 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: rename get_env_var to get_env_fallback
parent
71fd8983
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#12551
passed with warnings
3 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Pipeline: caosdb-cppinttest
#12553
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/caosdb/utility.h
+3
-3
3 additions, 3 deletions
include/caosdb/utility.h
include/ccaosdb.h
+1
-1
1 addition, 1 deletion
include/ccaosdb.h
src/ccaosdb.cpp
+2
-2
2 additions, 2 deletions
src/ccaosdb.cpp
test/test_ccaosdb.cpp
+3
-3
3 additions, 3 deletions
test/test_ccaosdb.cpp
with
9 additions
and
9 deletions
include/caosdb/utility.h
+
3
−
3
View file @
13b955a1
...
...
@@ -97,7 +97,7 @@ inline auto load_string_file(const path &path) -> std::string {
/**
* @brief Return the environment variable KEY, or FALLBACK if it does not exist.
*/
inline
auto
get_env_
var
(
const
char
*
key
,
const
char
*
fallback
)
->
const
char
*
{
inline
auto
get_env_
fallback
(
const
char
*
key
,
const
char
*
fallback
)
->
const
char
*
{
const
char
*
val
=
getenv
(
key
);
if
(
val
==
nullptr
)
{
return
fallback
;
...
...
@@ -110,8 +110,8 @@ inline auto get_env_var(const char *key, const char *fallback) -> const char * {
* @brief Return the value of an environment variable or - if undefined - the
* fallback value.
*/
inline
auto
get_env_
var
(
const
std
::
string
&
key
,
const
std
::
string
&
fallback
)
->
const
std
::
string
{
const
char
*
val
=
get_env_
var
(
key
.
c_str
(),
fallback
.
c_str
());
inline
auto
get_env_
fallback
(
const
std
::
string
&
key
,
const
std
::
string
&
fallback
)
->
const
std
::
string
{
const
char
*
val
=
get_env_
fallback
(
key
.
c_str
(),
fallback
.
c_str
());
auto
const
result
=
std
::
string
(
val
);
return
result
;
...
...
This diff is collapsed.
Click to expand it.
include/ccaosdb.h
+
1
−
1
View file @
13b955a1
...
...
@@ -112,7 +112,7 @@ typedef struct {
*
* If the environment variable is not set, return the fallback instead.
*/
const
char
*
caosdb_utility_get_env_
var
(
const
char
*
name
,
const
char
*
fallback
);
const
char
*
caosdb_utility_get_env_
fallback
(
const
char
*
name
,
const
char
*
fallback
);
/**
* Return a description of the status code.
...
...
This diff is collapsed.
Click to expand it.
src/ccaosdb.cpp
+
2
−
2
View file @
13b955a1
...
...
@@ -170,8 +170,8 @@ const char *caosdb_constants_COMPATIBLE_SERVER_VERSION_PRE_RELEASE() {
int
caosdb_status_code_OTHER_CLIENT_ERROR
()
{
return
caosdb
::
StatusCode
::
OTHER_CLIENT_ERROR
;
}
const
char
*
caosdb_utility_get_env_
var
(
const
char
*
name
,
const
char
*
fallback
)
{
return
caosdb
::
utility
::
get_env_
var
(
name
,
fallback
);
const
char
*
caosdb_utility_get_env_
fallback
(
const
char
*
name
,
const
char
*
fallback
)
{
return
caosdb
::
utility
::
get_env_
fallback
(
name
,
fallback
);
}
const
char
*
caosdb_get_status_description
(
int
code
)
{
...
...
This diff is collapsed.
Click to expand it.
test/test_ccaosdb.cpp
+
3
−
3
View file @
13b955a1
...
...
@@ -23,7 +23,7 @@
#include
"caosdb/configuration.h"
#include
"caosdb/status_code.h"
// for StatusCode
#include
"caosdb_test_utility.h"
// for EXPECT_THROW_MESSAGE, TEST_DATA_DIR
#include
"ccaosdb.h"
// for caosdb_utility_get_env_
var
#include
"ccaosdb.h"
// for caosdb_utility_get_env_
fallback
#include
<cstring>
// for strcmp
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for SuiteApiResolver, TestFactoryImpl
...
...
@@ -42,8 +42,8 @@ protected:
void
TearDown
()
override
{
caosdb
::
configuration
::
ConfigurationManager
::
Clear
();
}
};
TEST_F
(
test_ccaosdb
,
test_get_env_
var
)
{
const
char
*
const
some_var
=
caosdb_utility_get_env_
var
(
"SOME_ENV_VAR"
,
"fall-back"
);
TEST_F
(
test_ccaosdb
,
test_get_env_
fallback
)
{
const
char
*
const
some_var
=
caosdb_utility_get_env_
fallback
(
"SOME_ENV_VAR"
,
"fall-back"
);
EXPECT_EQ
(
"fall-back"
,
some_var
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment