test(queue): do not depend on the order of concurrent sends
This commit is contained in:
parent
e6713962f9
commit
b207312cef
1 changed files with 12 additions and 7 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue