Skip to content

Commit

Permalink
Fix Testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
developerkunal committed Mar 11, 2025
1 parent c1ca0d2 commit 0d3655b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions internal/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,13 @@ func TestRetries(t *testing.T) {
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
i++
if i == 1 {
futureTime := time.Now().Add(2 * time.Second).In(time.FixedZone("GMT", 0))
w.Header().Set("Retry-After", futureTime.Format(time.RFC1123))
w.WriteHeader(http.StatusTooManyRequests)
futureTime := time.Now().Add(5 * time.Second).UTC()
retryAfter := futureTime.Format(time.RFC1123)
retryAfter = strings.Replace(retryAfter, "UTC", "GMT", 1) // Ensure correct format
t.Logf("Setting Retry-After header to: %s", retryAfter)

time.Sleep(2 * time.Second)
w.Header().Set("Retry-After", retryAfter)
w.WriteHeader(http.StatusTooManyRequests)
return
}
w.WriteHeader(http.StatusOK)
Expand All @@ -585,8 +587,8 @@ func TestRetries(t *testing.T) {
elapsed := time.Since(start).Milliseconds()
t.Logf("Actual wait time: %dms", elapsed)

assert.GreaterOrEqual(t, elapsed, int64(2400), "Expected wait >= 2400ms, got %dms", elapsed)
assert.LessOrEqual(t, elapsed, int64(3500), "Expected wait <= 3500ms, got %dms", elapsed)
assert.GreaterOrEqual(t, elapsed, int64(6000), "Expected wait >= 6000ms, got %dms", elapsed)
assert.LessOrEqual(t, elapsed, int64(8000), "Expected wait <= 8000ms, got %dms", elapsed)
})
}

Expand Down

0 comments on commit 0d3655b

Please sign in to comment.