MCPcopy Create free account
hub / github.com/apache/qpid-proton / test_default_file

Function test_default_file

cpp/src/connect_config_test.cpp:81–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79using namespace proton;
80
81void test_default_file() {
82 // Default file locations in order of preference.
83 ::setenv("MESSAGING_CONNECT_FILE", "environment", 1);
84 ofstream("connect.json") << R"({ "host": "current" })" << endl;
85 ::setenv("HOME", "testdata", 1);
86 ofstream("testdata/.config/messaging/connect.json") << R"({ "host": ".config" })" << endl;
87 ASSERT_EQUAL("environment", connect_config::default_file());
88 ::unsetenv("MESSAGING_CONNECT_FILE");
89 ASSERT_EQUAL("connect.json", connect_config::default_file());
90 remove("connect.json");
91 ASSERT_EQUAL("testdata/.config/messaging/connect.json", connect_config::default_file());
92 remove("testdata/.config/messaging/connect.json");
93
94 // We can't fully test prefix and /etc locations, we have no control.
95 try {
96 ASSERT_SUBSTRING("/etc/messaging", connect_config::default_file());
97 } catch (...) {} // OK if not there
98}
99
100void test_addr() {
101 connection_options opts;

Callers 1

mainFunction · 0.85

Calls 3

setenvFunction · 0.85
unsetenvFunction · 0.85
default_fileFunction · 0.70

Tested by

no test coverage detected