Skip to content

Commit 4e7c141

Browse files
committed
Deprecate the test teardown function by moving teardown code into a test cleanup function
1 parent 65b39a6 commit 4e7c141

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gitlab_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,21 @@ func setup(t *testing.T) (*http.ServeMux, *httptest.Server, *Client) {
4343
// server is a test HTTP server used to provide mock API responses.
4444
server := httptest.NewServer(mux)
4545

46+
// TODO(asnyder): Individual tests no longer need to call `defer teardown()`.
47+
t.Cleanup(server.Close)
48+
4649
// client is the Gitlab client being tested.
4750
client, err := NewClient("", WithBaseURL(server.URL))
4851
if err != nil {
49-
server.Close()
5052
t.Fatalf("Failed to create client: %v", err)
5153
}
5254

5355
return mux, server, client
5456
}
5557

5658
// teardown closes the test HTTP server.
59+
//
60+
// Deprecated: The server will close itself without the need to call teardown() explicitly.
5761
func teardown(server *httptest.Server) {
5862
server.Close()
5963
}

0 commit comments

Comments
 (0)