diff options
| author | YDBot <[email protected]> | 2025-11-03 00:52:38 +0000 |
|---|---|---|
| committer | YDBot <[email protected]> | 2025-11-03 00:52:38 +0000 |
| commit | 2d490611a0e3097c111366eb9ea9e74d0a576209 (patch) | |
| tree | f7ab5825bb803bad02cf9acb6a63a3ed2ebcf042 /library/cpp/yt/system/unittests/env_ut.cpp | |
| parent | a3150c48bbea4bec90b1927434917736d248b4c9 (diff) | |
| parent | 73672db4e0da266a2d32be8e83983f1b556eb68d (diff) | |
Sync branches 251103-0051
Diffstat (limited to 'library/cpp/yt/system/unittests/env_ut.cpp')
| -rw-r--r-- | library/cpp/yt/system/unittests/env_ut.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/library/cpp/yt/system/unittests/env_ut.cpp b/library/cpp/yt/system/unittests/env_ut.cpp new file mode 100644 index 00000000000..21183a12390 --- /dev/null +++ b/library/cpp/yt/system/unittests/env_ut.cpp @@ -0,0 +1,52 @@ +#include <library/cpp/testing/gtest/gtest.h> + +#include <library/cpp/yt/system/env.h> + +#include <library/cpp/yt/misc/guid.h> + +#include <library/cpp/yt/string/format.h> + +#include <util/system/env.h> + +namespace NYT { +namespace { + +//////////////////////////////////////////////////////////////////////////////// + +TEST(TParseEnvironNameValuePairTest, NonNull) +{ + auto pair = ParseEnvironNameValuePair("var=value"); + EXPECT_EQ(pair.first, "var"); + EXPECT_EQ(pair.second, "value"); +} + +TEST(TParseEnvironNameValuePairTest, Null) +{ + auto pair = ParseEnvironNameValuePair("some"); + EXPECT_EQ(pair.first, "some"); + EXPECT_EQ(pair.second, std::nullopt); +} + +//////////////////////////////////////////////////////////////////////////////// + +#if defined(_linux_) || defined(_darwin_) + +TEST(TGetEnvironNameValuePairsTest, Simple) +{ + auto key = Format("var%v", TGuid::Create()); + auto value = TString("value"); + auto pair = Format("%v=%v", key, value); + SetEnv(key, value); + auto pairs = GetEnvironNameValuePairs(); + EXPECT_TRUE(std::ranges::find(pairs, pair) != pairs.end()); + UnsetEnv(key); +} + +#endif + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace +} // namespace NYT + + |
