@@ -321,6 +321,8 @@ func TestCreateNetworkpolicyInstance_AllowDenyFlags(t *testing.T) {
321321
322322func TestRunner_Process_And_RetryLoop (t * testing.T ) {
323323 var hits1 , hits2 int32
324+
325+ // srv1: returns 429 for the first 3 requests, and 200 on the 4th request
324326 srv1 := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
325327 if atomic .AddInt32 (& hits1 , 1 ) != 4 {
326328 w .WriteHeader (http .StatusTooManyRequests )
@@ -330,6 +332,7 @@ func TestRunner_Process_And_RetryLoop(t *testing.T) {
330332 }))
331333 defer srv1 .Close ()
332334
335+ // srv2: returns 429 for the first 2 requests, and 200 on the 3rd request
333336 srv2 := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
334337 if atomic .AddInt32 (& hits2 , 1 ) != 3 {
335338 w .WriteHeader (http .StatusTooManyRequests )
@@ -366,7 +369,7 @@ func TestRunner_Process_And_RetryLoop(t *testing.T) {
366369 var drainWG sync.WaitGroup
367370 drainWG .Add (1 )
368371 var s1n429 , s1n200 , s2n429 , s2n200 int
369- go func (output chan Result ) {
372+ go func () {
370373 defer drainWG .Done ()
371374 for res := range output {
372375 switch res .StatusCode {
@@ -384,7 +387,7 @@ func TestRunner_Process_And_RetryLoop(t *testing.T) {
384387 }
385388 }
386389 }
387- }(output )
390+ }()
388391
389392 for _ , url := range seed {
390393 r .process (url , wg , r .hp , httpx .HTTP , so , output , retryCh )
@@ -395,8 +398,12 @@ func TestRunner_Process_And_RetryLoop(t *testing.T) {
395398 close (output )
396399 drainWG .Wait ()
397400
401+ // Verify expected results
402+ // srv1: should have 3x 429 responses and no 200 (never succeeds within retries)
398403 require .Equal (t , 3 , s1n429 )
399404 require .Equal (t , 0 , s1n200 )
405+
406+ // srv2: should have 2x 429 responses and 1x 200 (succeeds on 3rd attempt)
400407 require .Equal (t , 2 , s2n429 )
401408 require .Equal (t , 1 , s2n200 )
402409}
0 commit comments