TestWantConnQueue_dropFrontDone_NoneDone tests dropFrontDone when no elements are done.
(t *testing.T)
| 557 | |
| 558 | // TestWantConnQueue_dropFrontDone_NoneDone tests dropFrontDone when no elements are done. |
| 559 | func TestWantConnQueue_dropFrontDone_NoneDone(t *testing.T) { |
| 560 | q := newWantConnQueue() |
| 561 | |
| 562 | // Create 3 wantConn items, none marked as done |
| 563 | for i := 0; i < 3; i++ { |
| 564 | w := &wantConn{ |
| 565 | ctx: context.Background(), |
| 566 | done: false, // Not done |
| 567 | result: make(chan wantConnResult, 1), |
| 568 | } |
| 569 | q.enqueue(w) |
| 570 | } |
| 571 | |
| 572 | // Verify initial queue length |
| 573 | if q.len() != 3 { |
| 574 | t.Errorf("initial queue length = %d, want 3", q.len()) |
| 575 | } |
| 576 | |
| 577 | // Call dropFrontDone |
| 578 | count := q.discardDoneAtFront() |
| 579 | |
| 580 | // Verify no elements were removed |
| 581 | if count != 0 { |
| 582 | t.Errorf("dropFrontDone() = %d, want 0", count) |
| 583 | } |
| 584 | |
| 585 | // Verify queue length unchanged |
| 586 | if q.len() != 3 { |
| 587 | t.Errorf("queue length after dropFrontDone = %d, want 3", q.len()) |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | // TestWantConnQueue_dropFrontDone_PartialDone tests dropFrontDone with mixed done/not-done elements. |
| 592 | // This is the core test case that verifies dropFrontDone stops at the first not-done element. |
nothing calls this directly
no test coverage detected