Skip to content

Commit

Permalink
Use defer to disable warnings as errors in test
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodm committed Aug 18, 2022
1 parent e8a9c56 commit d78a905
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions code/go/pkg/validator/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: ")
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit d78a905

Please sign in to comment.