mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 09:37:02 +00:00
message: Verify empty mailbox list does not error (#424)
Signed-off-by: James Hillyerd <james@hillyerd.com>
This commit is contained in:
@@ -118,13 +118,44 @@ func TestDeliverUsesBeforeMessageStoredEventResponseMailboxes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Expect messages in only the mailboxes in the event response, and for the DiscardDomains
|
// Expect messages in only the mailboxes in the event response, and for the DiscardDomains
|
||||||
// policy to be ignored.
|
// policy to be ignored for nostore.com.
|
||||||
assertMessageCount(t, sm, "u1@example.com", 0)
|
assertMessageCount(t, sm, "u1@example.com", 0)
|
||||||
assertMessageCount(t, sm, "u2@example.com", 0)
|
assertMessageCount(t, sm, "u2@example.com", 0)
|
||||||
assertMessageCount(t, sm, "new1@example.com", 1)
|
assertMessageCount(t, sm, "new1@example.com", 1)
|
||||||
assertMessageCount(t, sm, "new2@nostore.com", 1)
|
assertMessageCount(t, sm, "new2@nostore.com", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDeliverUsesBeforeMessageStoredEventResponseMailboxesEmpty(t *testing.T) {
|
||||||
|
sm, extHost := testStoreManager()
|
||||||
|
|
||||||
|
// Register function to receive event.
|
||||||
|
extHost.Events.BeforeMessageStored.AddListener(
|
||||||
|
"test",
|
||||||
|
func(msg event.InboundMessage) *event.InboundMessage {
|
||||||
|
// Listener clears destination mailboxes.
|
||||||
|
resp := msg
|
||||||
|
resp.Mailboxes = []string{}
|
||||||
|
return &resp
|
||||||
|
})
|
||||||
|
|
||||||
|
// Deliver a message to trigger event.
|
||||||
|
origin, _ := sm.AddrPolicy.ParseOrigin("from@example.com")
|
||||||
|
recip1, _ := sm.AddrPolicy.NewRecipient("u1@example.com")
|
||||||
|
recip2, _ := sm.AddrPolicy.NewRecipient("u2@example.com")
|
||||||
|
if err := sm.Deliver(
|
||||||
|
origin,
|
||||||
|
[]*policy.Recipient{recip1, recip2},
|
||||||
|
"Received: xyz\r\n",
|
||||||
|
[]byte("From: from@example.com\nSubject: tsub\n\ntest email"),
|
||||||
|
); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expect no messages the mailboxes.
|
||||||
|
assertMessageCount(t, sm, "u1@example.com", 0)
|
||||||
|
assertMessageCount(t, sm, "u2@example.com", 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestDeliverUsesBeforeMessageStoredEventResponseFields(t *testing.T) {
|
func TestDeliverUsesBeforeMessageStoredEventResponseFields(t *testing.T) {
|
||||||
sm, extHost := testStoreManager()
|
sm, extHost := testStoreManager()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user