Skip to content

Commit

Permalink
Use t.Cleanup() rather than defer to shutdown test servers
Browse files Browse the repository at this point in the history
Thanks @phillebaba!
  • Loading branch information
Lucas Rodriguez committed May 29, 2024
1 parent d22ca10 commit 6877b80
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/pkg/packager/sources/new_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestPackageSource(t *testing.T) {
defer f.Close()
io.Copy(rw, f)
}))
defer ts.Close()
t.Cleanup(func() { ts.Close() })

tests := []struct {
name string
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/utils/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestDownloadToFile(t *testing.T) {
}
rw.Write([]byte(content))
}))
defer srv.Close()
t.Cleanup(func() { srv.Close() })

tests := []struct {
name string
Expand Down

0 comments on commit 6877b80

Please sign in to comment.