From fe063911403ef78e3cbbc58ff1b47e85ae3c8fdd Mon Sep 17 00:00:00 2001 From: Alan Parra Date: Fri, 18 Oct 2024 15:41:50 -0300 Subject: [PATCH] Use t.Setenv Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com> --- lib/devicetrust/enroll/auto_enroll_test.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/devicetrust/enroll/auto_enroll_test.go b/lib/devicetrust/enroll/auto_enroll_test.go index a8d6b453538f..77a6678a9949 100644 --- a/lib/devicetrust/enroll/auto_enroll_test.go +++ b/lib/devicetrust/enroll/auto_enroll_test.go @@ -20,7 +20,6 @@ package enroll_test import ( "context" - "os" "testing" "github.com/stretchr/testify/assert" @@ -70,11 +69,7 @@ func TestAutoEnrollCeremony_Run(t *testing.T) { } func TestAutoEnroll_disabledByEnv(t *testing.T) { - // Don't t.Parallel, test changes env variables. - - const key = "TELEPORT_DEVICE_AUTO_ENROLL_DISABLED" - os.Setenv(key, "1") - t.Cleanup(func() { os.Unsetenv(key) }) + t.Setenv("TELEPORT_DEVICE_AUTO_ENROLL_DISABLED", "1") _, err := enroll.AutoEnroll(context.Background(), nil /* devicesClient */) assert.ErrorIs(t, err, enroll.ErrAutoEnrollDisabled, "AutoEnroll() error mismatch")