Skip to content

Commit

Permalink
Code review comments.
Browse files Browse the repository at this point in the history
Signed-off-by: naveensrinivasan <[email protected]>
  • Loading branch information
naveensrinivasan committed Jul 10, 2023
1 parent ba2cebd commit 31bc6f0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions clients/githubrepo/roundtripper/rate_limit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
)

func TestRoundTrip(t *testing.T) {
t.Parallel()
var requestCount int
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Customize the response headers and body based on the test scenario
Expand All @@ -38,7 +39,7 @@ func TestRoundTrip(t *testing.T) {
w.Write([]byte("Success")) // nolint: errcheck
} else {
// First request: Return Retry-After header
w.Header().Set("Retry-After", "5")
w.Header().Set("Retry-After", "1")
w.WriteHeader(http.StatusTooManyRequests)
w.Write([]byte("Rate Limit Exceeded")) // nolint: errcheck
}
Expand All @@ -48,7 +49,9 @@ func TestRoundTrip(t *testing.T) {
w.Write([]byte("Success")) // nolint: errcheck
}
}))
defer ts.Close()
t.Cleanup(func() {
defer ts.Close()
})

// Create the rateLimitTransport with the test server as the inner transport and a default logger
transport := &rateLimitTransport{
Expand Down

0 comments on commit 31bc6f0

Please sign in to comment.