@@ -353,7 +353,7 @@ func TestCalculateBackoff_MaxBackoffCap(t *testing.T) {
353353 }
354354}
355355
356- // Test isRateLimitError - all patterns
356+ // Test IsRateLimitErrorMessage - all patterns
357357func TestIsRateLimitError_AllPatterns (t * testing.T ) {
358358 // Test all patterns from rateLimitPatterns
359359 patterns := []string {
@@ -382,36 +382,36 @@ func TestIsRateLimitError_AllPatterns(t *testing.T) {
382382 for _ , pattern := range patterns {
383383 t .Run (fmt .Sprintf ("Pattern_%s" , strings .ReplaceAll (pattern , " " , "_" )), func (t * testing.T ) {
384384 // Test exact match
385- if ! isRateLimitError (pattern ) {
385+ if ! IsRateLimitErrorMessage (pattern ) {
386386 t .Errorf ("Pattern '%s' should be detected as rate limit error" , pattern )
387387 }
388388
389389 // Test case insensitive - uppercase
390- if ! isRateLimitError (strings .ToUpper (pattern )) {
390+ if ! IsRateLimitErrorMessage (strings .ToUpper (pattern )) {
391391 t .Errorf ("Uppercase pattern '%s' should be detected as rate limit error" , strings .ToUpper (pattern ))
392392 }
393393
394394 // Test case insensitive - mixed case
395- if ! isRateLimitError (strings .Title (pattern )) {
395+ if ! IsRateLimitErrorMessage (strings .Title (pattern )) {
396396 t .Errorf ("Title case pattern '%s' should be detected as rate limit error" , strings .Title (pattern ))
397397 }
398398
399399 // Test as part of larger message
400400 message := fmt .Sprintf ("Error: %s occurred" , pattern )
401- if ! isRateLimitError (message ) {
401+ if ! IsRateLimitErrorMessage (message ) {
402402 t .Errorf ("Pattern '%s' in message '%s' should be detected" , pattern , message )
403403 }
404404
405405 // Test with prefix and suffix
406406 message = fmt .Sprintf ("API call failed due to %s - please retry later" , pattern )
407- if ! isRateLimitError (message ) {
407+ if ! IsRateLimitErrorMessage (message ) {
408408 t .Errorf ("Pattern '%s' in complex message should be detected" , pattern )
409409 }
410410 })
411411 }
412412}
413413
414- // Test isRateLimitError - negative cases
414+ // Test IsRateLimitErrorMessage - negative cases
415415func TestIsRateLimitError_NegativeCases (t * testing.T ) {
416416 negativeCases := []string {
417417 "" ,
@@ -431,31 +431,31 @@ func TestIsRateLimitError_NegativeCases(t *testing.T) {
431431
432432 for _ , testCase := range negativeCases {
433433 t .Run (fmt .Sprintf ("Negative_%s" , strings .ReplaceAll (testCase , " " , "_" )), func (t * testing.T ) {
434- if isRateLimitError (testCase ) {
434+ if IsRateLimitErrorMessage (testCase ) {
435435 t .Errorf ("Message '%s' should NOT be detected as rate limit error" , testCase )
436436 }
437437 })
438438 }
439439}
440440
441- // Test isRateLimitError - edge cases
441+ // Test IsRateLimitErrorMessage - edge cases
442442func TestIsRateLimitError_EdgeCases (t * testing.T ) {
443443 t .Run ("EmptyString" , func (t * testing.T ) {
444- if isRateLimitError ("" ) {
444+ if IsRateLimitErrorMessage ("" ) {
445445 t .Error ("Empty string should not be detected as rate limit error" )
446446 }
447447 })
448448
449449 t .Run ("OnlyWhitespace" , func (t * testing.T ) {
450- if isRateLimitError (" \t \n " ) {
450+ if IsRateLimitErrorMessage (" \t \n " ) {
451451 t .Error ("Whitespace-only string should not be detected as rate limit error" )
452452 }
453453 })
454454
455455 t .Run ("UnicodeCharacters" , func (t * testing.T ) {
456456 // Test with unicode characters that might affect case conversion
457457 message := "RATE LIMIT exceeded 🚫"
458- if ! isRateLimitError (message ) {
458+ if ! IsRateLimitErrorMessage (message ) {
459459 t .Error ("Message with unicode should still detect rate limit pattern" )
460460 }
461461 })
@@ -544,7 +544,7 @@ func BenchmarkCalculateBackoff(b *testing.B) {
544544 }
545545}
546546
547- // Benchmark isRateLimitError performance
547+ // Benchmark IsRateLimitErrorMessage performance
548548func BenchmarkIsRateLimitError (b * testing.B ) {
549549 messages := []string {
550550 "rate limit exceeded" ,
@@ -559,7 +559,7 @@ func BenchmarkIsRateLimitError(b *testing.B) {
559559
560560 b .ResetTimer ()
561561 for i := 0 ; i < b .N ; i ++ {
562- isRateLimitError (messages [i % len (messages )])
562+ IsRateLimitErrorMessage (messages [i % len (messages )])
563563 }
564564}
565565
0 commit comments