diff --git a/internal/queue/queue_test.go b/internal/queue/queue_test.go index b8e185c..69cc74a 100644 --- a/internal/queue/queue_test.go +++ b/internal/queue/queue_test.go @@ -109,15 +109,20 @@ func TestDeliversPrefixPlusMessage(t *testing.T) { if e.pending(t) != 0 { t.Fatal("sent items must leave the queue") } - got := e.snd.sent[0] - if got.From != "bounce@x.org" || len(got.To) != 1 || got.To[0] != "a@x.com" { - t.Fatalf("envelope: %+v", got) + // Sends run concurrently, so look recipients up instead of relying on order. + byRcpt := map[string]outbound.Sent{} + for _, m := range e.snd.sent { + byRcpt[m.To[0]] = m } - if string(got.Data) != "X-Rcpt: a\r\nSubject: hi\r\n\r\nbody\r\n" { - t.Fatalf("data = %q", got.Data) + a, b := byRcpt["a@x.com"], byRcpt["b@x.com"] + if a.From != "bounce@x.org" || len(a.To) != 1 { + t.Fatalf("envelope: %+v", a) } - if string(e.snd.sent[1].Data) != "X-Rcpt: b\r\nSubject: hi\r\n\r\nbody\r\n" { - t.Fatalf("each recipient has its own prefix: %q", e.snd.sent[1].Data) + if string(a.Data) != "X-Rcpt: a\r\nSubject: hi\r\n\r\nbody\r\n" { + t.Fatalf("data = %q", a.Data) + } + if string(b.Data) != "X-Rcpt: b\r\nSubject: hi\r\n\r\nbody\r\n" { + t.Fatalf("each recipient has its own prefix: %q", b.Data) } }