From e243cf4cee3a09946dbc7fac7ae42a283c719f84 Mon Sep 17 00:00:00 2001 From: Geon Kim Date: Wed, 10 Jan 2024 02:02:23 +0900 Subject: [PATCH] test(memlimit): rollback environment variable after testing --- memlimit/experiment_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/memlimit/experiment_test.go b/memlimit/experiment_test.go index a766322..162134f 100644 --- a/memlimit/experiment_test.go +++ b/memlimit/experiment_test.go @@ -45,6 +45,15 @@ func TestParseExperiments(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + exp, ok := os.LookupEnv(envAUTOMEMLIMIT_EXPERIMENT) + t.Cleanup(func() { + if ok { + os.Setenv(envAUTOMEMLIMIT_EXPERIMENT, exp) + } else { + os.Unsetenv(envAUTOMEMLIMIT_EXPERIMENT) + } + }) + os.Setenv("AUTOMEMLIMIT_EXPERIMENT", tt.env) exps, err := parseExperiments() if !reflect.DeepEqual(exps, tt.want) {