Skip to content

Commit 50c96ee

Browse files
committed
... use putenv on windows
1 parent 53776dc commit 50c96ee

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/src/unit/tests/test_connection.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
using namespace datastax::internal;
3434
using namespace datastax::internal::core;
3535

36+
namespace {
37+
38+
static void setenv(const std::string& name, const std::string& value) {
39+
#ifdef _WIN32
40+
putenv(const_cast<char*>(std::string(name + "=" + value).c_str()));
41+
#else
42+
::setenv(name.c_str(), value.c_str(), 1);
43+
#endif
44+
}
45+
46+
}
47+
3648
class ConnectionUnitTest : public LoopTest {
3749
public:
3850
enum Status {
@@ -220,8 +232,7 @@ TEST_F(ConnectionUnitTest, SslDefaultVerifyPaths) {
220232
std::ofstream cert_buffer(cert_path.c_str());
221233
cert_buffer << cert;
222234
cert_buffer.close();
223-
ASSERT_EQ(::setenv("SSL_CERT_FILE", cert_path.c_str(), 1), 0)
224-
<< "Failed to prepare openssl environment";
235+
setenv("SSL_CERT_FILE", cert_path.c_str());
225236
std::cout << "Debug SslDefaultVerifyPaths: SSL_CERT_FILE " << cert_path << " " << cert << std::endl;
226237
for (const auto var: {"SSL_CERT_FILE", "SSL_CERT_DIR"}) {
227238
const char* value = std::getenv(var);

0 commit comments

Comments
 (0)