Skip to content

Commit

Permalink
Added basic test for windows for getting environment variables alread…
Browse files Browse the repository at this point in the history
…y existing. This might also catch issues with home paths containing unicode.
  • Loading branch information
Klaim committed Mar 30, 2023
1 parent 71bac1c commit 579a65b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions libmamba/tests/src/core/test_system_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,25 @@ TEST(system_env, set_get_unset_variables_unicode)

test_set_get_unset_env_variables(key, value);
}

#ifdef _WIN32

TEST(system_env, get_predefined_env_variable)
{
// We check that normal pre-defined variables are accessible and do not fail access even if some
// of these values have unicode.
const std::vector<std::string> predefined_keys{ "PATH", "OS", "PATHEXT",
"ProgramData", "SystemRoot", "windir",
"APPDATA", "COMPUTERNAME", "TEMP",
"UserName", "USERPROFILE" };

for (const auto& key : predefined_keys)
{
const auto maybe_value = mamba::env::get(key);
ASSERT_TRUE(maybe_value.has_value()) << "key = " + key;
const auto value = *maybe_value;
EXPECT_FALSE(value.empty()) << "key = " + key;
}
}

#endif

0 comments on commit 579a65b

Please sign in to comment.