mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-18 14:47:03 +00:00
queue: Simplify sending loop
This patch simplifies the sending loop code: - Move the recipient sending function from a closure to a method. - Simplify the status update logic: we now update and write unconditionally (as we should have been doing). - Create a function for counting recipients in a given status. It also adds a test for the removal of completed items from the queue, which was not covered before and came up during development.
This commit is contained in:
@@ -80,6 +80,17 @@ func TestBasic(t *testing.T) {
|
||||
localC.wg.Wait()
|
||||
remoteC.wg.Wait()
|
||||
|
||||
// Make sure the delivered items leave the queue.
|
||||
for d := time.Now().Add(2 * time.Second); time.Now().Before(d); {
|
||||
if q.Len() == 0 {
|
||||
break
|
||||
}
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
}
|
||||
if q.Len() != 0 {
|
||||
t.Fatalf("%d items not removed from the queue after delivery", q.Len())
|
||||
}
|
||||
|
||||
cases := []struct {
|
||||
courier *TestCourier
|
||||
expectedTo string
|
||||
|
||||
Reference in New Issue
Block a user