Skip to content

Commit

Permalink
Deprecate the test teardown function by moving teardown code into a t…
Browse files Browse the repository at this point in the history
…est cleanup function
  • Loading branch information
armsnyder committed Dec 11, 2022
1 parent 05207f5 commit cf792e7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gitlab_test.go
Expand Up @@ -43,17 +43,21 @@ func setup(t *testing.T) (*http.ServeMux, *httptest.Server, *Client) {
// server is a test HTTP server used to provide mock API responses.
server := httptest.NewServer(mux)

// TODO(asnyder): Individual tests no longer need to call `defer teardown()`.
t.Cleanup(server.Close)

// client is the Gitlab client being tested.
client, err := NewClient("", WithBaseURL(server.URL))
if err != nil {
server.Close()
t.Fatalf("Failed to create client: %v", err)
}

return mux, server, client
}

// teardown closes the test HTTP server.
//
// Deprecated: The server will close itself without the need to call teardown() explicitly.
func teardown(server *httptest.Server) {
server.Close()
}
Expand Down

0 comments on commit cf792e7

Please sign in to comment.