1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include <library/cpp/testing/common/scope.h>
#include <util/system/env.h>
#include <library/cpp/testing/gtest/gtest.h>
TEST(TScopedEnvironment, SingleValue) {
auto before = GetEnv("ARCADIA_SOURCE_ROOT");
{
NTesting::TScopedEnvironment guard("ARCADIA_SOURCE_ROOT", "source");
EXPECT_EQ("source", GetEnv("ARCADIA_SOURCE_ROOT"));
}
EXPECT_EQ(before, GetEnv("ARCADIA_SOURCE_ROOT"));
}
TEST(TScopedEnvironment, MultiValue) {
TVector<TString> before{GetEnv("ARCADIA_SOURCE_ROOT"), GetEnv("ARCADIA_BUILD_ROOT")};
{
NTesting::TScopedEnvironment guard{{
{"ARCADIA_SOURCE_ROOT", "source"},
{"ARCADIA_BUILD_ROOT", "build"},
}};
EXPECT_EQ("source", GetEnv("ARCADIA_SOURCE_ROOT"));
EXPECT_EQ("build", GetEnv("ARCADIA_BUILD_ROOT"));
}
TVector<TString> after{GetEnv("ARCADIA_SOURCE_ROOT"), GetEnv("ARCADIA_BUILD_ROOT")};
EXPECT_EQ(before, after);
}
|