From d78a905fd84609be8e6a5a3948aec8848c010189 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Date: Thu, 18 Aug 2022 12:17:08 +0200 Subject: [PATCH] Use defer to disable warnings as errors in test --- code/go/pkg/validator/validator_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code/go/pkg/validator/validator_test.go b/code/go/pkg/validator/validator_test.go index d4bd4ef12..963029bab 100644 --- a/code/go/pkg/validator/validator_test.go +++ b/code/go/pkg/validator/validator_test.go @@ -319,6 +319,8 @@ func TestValidateWarnings(t *testing.T) { if err := common.EnableWarningsAsErrors(); err != nil { require.NoError(t, err) } + defer common.DisableWarningsAsErrors() + for pkgName, expectedWarnContains := range tests { t.Run(pkgName, func(t *testing.T) { warnPrefix := fmt.Sprintf("Warning: ") @@ -347,9 +349,6 @@ func TestValidateWarnings(t *testing.T) { } }) } - if err := common.DisableWarningsAsErrors(); err != nil { - require.NoError(t, err) - } } func requireErrorMessage(t *testing.T, pkgName string, invalidItemsPerFolder map[string][]string, expectedErrorMessage string) {