X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=dmaap-mediator-producer%2Finternal%2Fconfig%2Fconfig_test.go;h=4a65dc0db92ef310bb8ea6d8fb33bf4e36f5f3d9;hb=refs%2Fchanges%2F03%2F6703%2F1;hp=23227399863648fa5ab955026d58a9a6976ab51e;hpb=f93e105a428fcf22795effb23ac17f1472ba5f7e;p=nonrtric.git diff --git a/dmaap-mediator-producer/internal/config/config_test.go b/dmaap-mediator-producer/internal/config/config_test.go index 23227399..4a65dc0d 100644 --- a/dmaap-mediator-producer/internal/config/config_test.go +++ b/dmaap-mediator-producer/internal/config/config_test.go @@ -37,7 +37,9 @@ func TestNew_envVarsSetConfigContainSetValues(t *testing.T) { os.Setenv("INFO_JOB_CALLBACK_HOST", "jobCallbackHost") os.Setenv("INFO_JOB_CALLBACK_PORT", "8096") os.Setenv("INFO_COORD_ADDR", "infoCoordAddr") - defer os.Clearenv() + t.Cleanup(func() { + os.Clearenv() + }) wantConfig := Config{ LogLevel: "Debug", InfoProducerSupervisionCallbackHost: "supervisionCallbackHost", @@ -52,16 +54,15 @@ func TestNew_envVarsSetConfigContainSetValues(t *testing.T) { } func TestNew_faultyIntValueSetConfigContainDefaultValueAndWarnInLog(t *testing.T) { - os.Clearenv() assertions := require.New(t) var buf bytes.Buffer log.SetOutput(&buf) - defer func() { - log.SetOutput(os.Stderr) - }() os.Setenv("INFO_PRODUCER_SUPERVISION_CALLBACK_PORT", "wrong") - defer os.Clearenv() + t.Cleanup(func() { + log.SetOutput(os.Stderr) + os.Clearenv() + }) wantConfig := Config{ LogLevel: "Info", InfoProducerSupervisionCallbackHost: "", @@ -78,7 +79,6 @@ func TestNew_faultyIntValueSetConfigContainDefaultValueAndWarnInLog(t *testing.T } func TestNew_envVarsNotSetConfigContainDefaultValues(t *testing.T) { - os.Clearenv() wantConfig := Config{ LogLevel: "Info", InfoProducerSupervisionCallbackHost: "",