mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 09:37:02 +00:00
storage: Store addresses as mail.Address for #69
This commit is contained in:
@@ -36,8 +36,8 @@ func MailboxListV1(w http.ResponseWriter, req *http.Request, ctx *web.Context) (
|
||||
jmessages[i] = &model.JSONMessageHeaderV1{
|
||||
Mailbox: name,
|
||||
ID: msg.ID(),
|
||||
From: msg.From(),
|
||||
To: msg.To(),
|
||||
From: msg.From().String(),
|
||||
To: stringutil.StringAddressList(msg.To()),
|
||||
Subject: msg.Subject(),
|
||||
Date: msg.Date(),
|
||||
Size: msg.Size(),
|
||||
@@ -90,8 +90,8 @@ func MailboxShowV1(w http.ResponseWriter, req *http.Request, ctx *web.Context) (
|
||||
&model.JSONMessageV1{
|
||||
Mailbox: name,
|
||||
ID: msg.ID(),
|
||||
From: msg.From(),
|
||||
To: msg.To(),
|
||||
From: msg.From().String(),
|
||||
To: stringutil.StringAddressList(msg.To()),
|
||||
Subject: msg.Subject(),
|
||||
Date: msg.Date(),
|
||||
Size: msg.Size(),
|
||||
|
||||
@@ -67,16 +67,16 @@ func TestRestMailboxList(t *testing.T) {
|
||||
data1 := &InputMessageData{
|
||||
Mailbox: "good",
|
||||
ID: "0001",
|
||||
From: "from1",
|
||||
To: []string{"to1"},
|
||||
From: "<from1@host>",
|
||||
To: []string{"<to1@host>"},
|
||||
Subject: "subject 1",
|
||||
Date: time.Date(2012, 2, 1, 10, 11, 12, 253, time.FixedZone("PST", -800)),
|
||||
}
|
||||
data2 := &InputMessageData{
|
||||
Mailbox: "good",
|
||||
ID: "0002",
|
||||
From: "from2",
|
||||
To: []string{"to1"},
|
||||
From: "<from2@host>",
|
||||
To: []string{"<to1@host>"},
|
||||
Subject: "subject 2",
|
||||
Date: time.Date(2012, 7, 1, 10, 11, 12, 253, time.FixedZone("PDT", -700)),
|
||||
}
|
||||
@@ -171,7 +171,7 @@ func TestRestMessage(t *testing.T) {
|
||||
data1 := &InputMessageData{
|
||||
Mailbox: "good",
|
||||
ID: "0001",
|
||||
From: "from1",
|
||||
From: "<from1@host>",
|
||||
Subject: "subject 1",
|
||||
Date: time.Date(2012, 2, 1, 10, 11, 12, 253, time.FixedZone("PST", -800)),
|
||||
Header: mail.Header{
|
||||
|
||||
@@ -26,10 +26,15 @@ type InputMessageData struct {
|
||||
}
|
||||
|
||||
func (d *InputMessageData) MockMessage() *storage.MockMessage {
|
||||
from, _ := mail.ParseAddress(d.From)
|
||||
to := make([]*mail.Address, len(d.To))
|
||||
for i, a := range d.To {
|
||||
to[i], _ = mail.ParseAddress(a)
|
||||
}
|
||||
msg := &storage.MockMessage{}
|
||||
msg.On("ID").Return(d.ID)
|
||||
msg.On("From").Return(d.From)
|
||||
msg.On("To").Return(d.To)
|
||||
msg.On("From").Return(from)
|
||||
msg.On("To").Return(to)
|
||||
msg.On("Subject").Return(d.Subject)
|
||||
msg.On("Date").Return(d.Date)
|
||||
msg.On("Size").Return(d.Size)
|
||||
|
||||
Reference in New Issue
Block a user