From 7bc9bdcb2dc5353c1972066dd79c574e03b45db5 Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Fri, 2 Jun 2023 00:52:01 -0700 Subject: [PATCH] apply code review --- internal/common/common_linux.go | 1 - internal/common/common_test.go | 12 ++---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/internal/common/common_linux.go b/internal/common/common_linux.go index 9c9088d14..b58edbeb0 100644 --- a/internal/common/common_linux.go +++ b/internal/common/common_linux.go @@ -30,7 +30,6 @@ func DoSysctrl(mib string) ([]string, error) { return values, nil } -// Deprecated: use NumProcsWithContext instead func NumProcs() (uint64, error) { return NumProcsWithContext(context.Background()) } diff --git a/internal/common/common_test.go b/internal/common/common_test.go index 43638bf49..424ea26ab 100644 --- a/internal/common/common_test.go +++ b/internal/common/common_test.go @@ -178,11 +178,7 @@ func TestGetEnvWithNoContext(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("windows doesn't have etc") } - old := os.Getenv("HOST_ETC") - os.Setenv("HOST_ETC", "/bar") - defer func() { - os.Setenv("HOST_ETC", old) - }() + t.Setenv("HOST_ETC", "/bar") p := HostEtcWithContext(context.Background(), "mtab") if p != "/bar/mtab" { t.Errorf("invalid HostEtc, %s", p) @@ -193,11 +189,7 @@ func TestGetEnvWithContextOverride(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("windows doesn't have etc") } - old := os.Getenv("HOST_ETC") - os.Setenv("HOST_ETC", "/bar") - defer func() { - os.Setenv("HOST_ETC", old) - }() + t.Setenv("HOST_ETC", "/bar") ctx := context.WithValue(context.Background(), common.EnvKey, common.EnvMap{common.HostEtcEnvKey: "/foo"}) p := HostEtcWithContext(ctx, "mtab") if p != "/foo/mtab" {