Skip to content

Commit 297f873

Browse files
authored
Merge pull request #185 from marquiz/devel/golangci-lint-5
test/chore: only close file if open succeeded
2 parents c7cee40 + 87b7c84 commit 297f873

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

schema/schema_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ func readAndValidate(t *testing.T, scm *schema.Schema, path string, shouldLoad,
286286
)
287287

288288
f, err := os.Open(path)
289-
defer f.Close()
290289
require.NoError(t, err)
290+
defer f.Close()
291291

292292
if scm != nil {
293293
data, err = scm.ReadAndValidate(f)
@@ -308,8 +308,8 @@ func readAndValidate(t *testing.T, scm *schema.Schema, path string, shouldLoad,
308308

309309
func validateRead(t *testing.T, scm *schema.Schema, path string, shouldLoad, isValid bool) {
310310
f, err := os.Open(path)
311-
defer f.Close()
312311
require.NoError(t, err)
312+
defer f.Close()
313313

314314
buf := &bytes.Buffer{}
315315
r := io.TeeReader(f, buf)

0 commit comments

Comments
 (0)