TestWantConnQueue_dropFrontDone_AllDone tests dropFrontDone when all elements are done.
(t *testing.T)
| 524 | |
| 525 | // TestWantConnQueue_dropFrontDone_AllDone tests dropFrontDone when all elements are done. |
| 526 | func TestWantConnQueue_dropFrontDone_AllDone(t *testing.T) { |
| 527 | q := newWantConnQueue() |
| 528 | |
| 529 | // Create 3 wantConn items, all marked as done |
| 530 | for i := 0; i < 3; i++ { |
| 531 | w := &wantConn{ |
| 532 | ctx: context.Background(), |
| 533 | done: true, // Mark as done |
| 534 | result: make(chan wantConnResult, 1), |
| 535 | } |
| 536 | q.enqueue(w) |
| 537 | } |
| 538 | |
| 539 | // Verify initial queue length |
| 540 | if q.len() != 3 { |
| 541 | t.Errorf("initial queue length = %d, want 3", q.len()) |
| 542 | } |
| 543 | |
| 544 | // Call dropFrontDone |
| 545 | count := q.discardDoneAtFront() |
| 546 | |
| 547 | // Verify all 3 elements were removed |
| 548 | if count != 3 { |
| 549 | t.Errorf("dropFrontDone() = %d, want 3", count) |
| 550 | } |
| 551 | |
| 552 | // Verify queue is now empty |
| 553 | if q.len() != 0 { |
| 554 | t.Errorf("queue length after dropFrontDone = %d, want 0", q.len()) |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | // TestWantConnQueue_dropFrontDone_NoneDone tests dropFrontDone when no elements are done. |
| 559 | func TestWantConnQueue_dropFrontDone_NoneDone(t *testing.T) { |
nothing calls this directly
no test coverage detected