@@ -468,17 +468,19 @@ func TestNewGitHubAPIErrorResponse_RateLimits(t *testing.T) {
468468 // Given a context with GitHub error tracking enabled
469469 ctx := ContextWithGitHubErrors (context .Background ())
470470
471- resetTime := time .Now ().Add (3 * time .Minute )
471+ resetTime := time .Now ().Add (30 * time .Minute )
472472 rateLimitErr := & github.RateLimitError {
473473 Rate : github.Rate {Reset : github.Timestamp {Time : resetTime }},
474474 Response : & http.Response {StatusCode : 403 },
475475 Message : "API rate limit exceeded" ,
476476 }
477477 resp := & github.Response {Response : rateLimitErr .Response }
478478
479+ // Capture expected duration before the call so both use the same time.Until snapshot
480+ expectedRetryIn := time .Until (resetTime ).Round (time .Second )
481+
479482 // When we create an API error response for a rate limit error
480483 result := NewGitHubAPIErrorResponse (ctx , "search code" , resp , rateLimitErr )
481- expectedRetryIn := time .Until (resetTime ).Round (time .Second )
482484
483485 // Then it should return an MCP error result
484486 require .NotNil (t , result )
@@ -600,7 +602,7 @@ func TestNewGitHubAPIErrorResponse_RateLimits(t *testing.T) {
600602 t .Run ("wrapped RateLimitError is handled via errors.As" , func (t * testing.T ) {
601603 ctx := ContextWithGitHubErrors (context .Background ())
602604
603- resetTime := time .Now ().Add (2 * time .Minute )
605+ resetTime := time .Now ().Add (20 * time .Minute )
604606 rateLimitErr := & github.RateLimitError {
605607 Rate : github.Rate {Reset : github.Timestamp {Time : resetTime }},
606608 Response : & http.Response {StatusCode : 403 },
@@ -609,9 +611,11 @@ func TestNewGitHubAPIErrorResponse_RateLimits(t *testing.T) {
609611 wrappedErr := fmt .Errorf ("transport layer: %w" , rateLimitErr )
610612 resp := & github.Response {Response : rateLimitErr .Response }
611613
612- result := NewGitHubAPIErrorResponse ( ctx , "search code" , resp , wrappedErr )
614+ // Capture expected duration before the call so both use the same time.Until snapshot
613615 expectedRetryIn := time .Until (resetTime ).Round (time .Second )
614616
617+ result := NewGitHubAPIErrorResponse (ctx , "search code" , resp , wrappedErr )
618+
615619 require .NotNil (t , result )
616620 assert .True (t , result .IsError )
617621 textContent := result .Content [0 ].(* mcp.TextContent )
0 commit comments