mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
corrected tests
This commit is contained in:
committed by
James Hillyerd
parent
124f830478
commit
02eee0a608
@@ -112,7 +112,7 @@ func MailboxShowV1(w http.ResponseWriter, req *http.Request, ctx *httpd.Context)
|
|||||||
Mailbox: name,
|
Mailbox: name,
|
||||||
ID: msg.ID(),
|
ID: msg.ID(),
|
||||||
From: msg.From(),
|
From: msg.From(),
|
||||||
To: msg.To(),
|
To: msg.To(),
|
||||||
Subject: msg.Subject(),
|
Subject: msg.Subject(),
|
||||||
Date: msg.Date(),
|
Date: msg.Date(),
|
||||||
Size: msg.Size(),
|
Size: msg.Size(),
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const (
|
|||||||
mailboxKey = "mailbox"
|
mailboxKey = "mailbox"
|
||||||
idKey = "id"
|
idKey = "id"
|
||||||
fromKey = "from"
|
fromKey = "from"
|
||||||
|
toKey = "to"
|
||||||
subjectKey = "subject"
|
subjectKey = "subject"
|
||||||
dateKey = "date"
|
dateKey = "date"
|
||||||
sizeKey = "size"
|
sizeKey = "size"
|
||||||
@@ -94,6 +95,7 @@ func TestRestMailboxList(t *testing.T) {
|
|||||||
Mailbox: "good",
|
Mailbox: "good",
|
||||||
ID: "0001",
|
ID: "0001",
|
||||||
From: "from1",
|
From: "from1",
|
||||||
|
To: "to1",
|
||||||
Subject: "subject 1",
|
Subject: "subject 1",
|
||||||
Date: time.Date(2012, 2, 1, 10, 11, 12, 253, time.FixedZone("PST", -800)),
|
Date: time.Date(2012, 2, 1, 10, 11, 12, 253, time.FixedZone("PST", -800)),
|
||||||
}
|
}
|
||||||
@@ -101,6 +103,7 @@ func TestRestMailboxList(t *testing.T) {
|
|||||||
Mailbox: "good",
|
Mailbox: "good",
|
||||||
ID: "0002",
|
ID: "0002",
|
||||||
From: "from2",
|
From: "from2",
|
||||||
|
To: "to1",
|
||||||
Subject: "subject 2",
|
Subject: "subject 2",
|
||||||
Date: time.Date(2012, 7, 1, 10, 11, 12, 253, time.FixedZone("PDT", -700)),
|
Date: time.Date(2012, 7, 1, 10, 11, 12, 253, time.FixedZone("PDT", -700)),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ func (m *MockMessage) From() string {
|
|||||||
return args.String(0)
|
return args.String(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MockMessage) To() string {
|
||||||
|
args := m.Called()
|
||||||
|
return args.String(0)
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MockMessage) Date() time.Time {
|
func (m *MockMessage) Date() time.Time {
|
||||||
args := m.Called()
|
args := m.Called()
|
||||||
return args.Get(0).(time.Time)
|
return args.Get(0).(time.Time)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
|
|
||||||
type InputMessageData struct {
|
type InputMessageData struct {
|
||||||
Mailbox, ID, From, Subject string
|
Mailbox, ID, From, Subject string
|
||||||
|
To string
|
||||||
Date time.Time
|
Date time.Time
|
||||||
Size int
|
Size int
|
||||||
Header mail.Header
|
Header mail.Header
|
||||||
@@ -27,6 +28,7 @@ func (d *InputMessageData) MockMessage() *MockMessage {
|
|||||||
msg := &MockMessage{}
|
msg := &MockMessage{}
|
||||||
msg.On("ID").Return(d.ID)
|
msg.On("ID").Return(d.ID)
|
||||||
msg.On("From").Return(d.From)
|
msg.On("From").Return(d.From)
|
||||||
|
msg.On("To").Return(d.To)
|
||||||
msg.On("Subject").Return(d.Subject)
|
msg.On("Subject").Return(d.Subject)
|
||||||
msg.On("Date").Return(d.Date)
|
msg.On("Date").Return(d.Date)
|
||||||
msg.On("Size").Return(d.Size)
|
msg.On("Size").Return(d.Size)
|
||||||
@@ -79,6 +81,9 @@ func (d *InputMessageData) CompareToJSONHeaderMap(json interface{}) (errors []st
|
|||||||
if msg, ok := isJSONStringEqual(fromKey, d.From, m[fromKey]); !ok {
|
if msg, ok := isJSONStringEqual(fromKey, d.From, m[fromKey]); !ok {
|
||||||
errors = append(errors, msg)
|
errors = append(errors, msg)
|
||||||
}
|
}
|
||||||
|
if msg, ok := isJSONStringEqual(toKey, d.To, m[toKey]); !ok {
|
||||||
|
errors = append(errors, msg)
|
||||||
|
}
|
||||||
if msg, ok := isJSONStringEqual(subjectKey, d.Subject, m[subjectKey]); !ok {
|
if msg, ok := isJSONStringEqual(subjectKey, d.Subject, m[subjectKey]); !ok {
|
||||||
errors = append(errors, msg)
|
errors = append(errors, msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,11 @@ func (m *MockMessage) From() string {
|
|||||||
return args.String(0)
|
return args.String(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MockMessage) To() string {
|
||||||
|
args := m.Called()
|
||||||
|
return args.String(0)
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MockMessage) Date() time.Time {
|
func (m *MockMessage) Date() time.Time {
|
||||||
args := m.Called()
|
args := m.Called()
|
||||||
return args.Get(0).(time.Time)
|
return args.Get(0).(time.Time)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ type OutputJSONHeader struct {
|
|||||||
Mailbox string
|
Mailbox string
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
From, Subject, Date string
|
From, Subject, Date string
|
||||||
|
To string
|
||||||
Size int
|
Size int
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ type OutputJSONMessage struct {
|
|||||||
Mailbox string
|
Mailbox string
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
From, Subject, Date string
|
From, Subject, Date string
|
||||||
|
To string
|
||||||
Size int
|
Size int
|
||||||
Header map[string][]string
|
Header map[string][]string
|
||||||
Body struct {
|
Body struct {
|
||||||
@@ -46,6 +48,7 @@ type InputMessageData struct {
|
|||||||
Mailbox string
|
Mailbox string
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
From, Subject string
|
From, Subject string
|
||||||
|
To string
|
||||||
Date time.Time
|
Date time.Time
|
||||||
Size int
|
Size int
|
||||||
Header mail.Header
|
Header mail.Header
|
||||||
@@ -57,6 +60,7 @@ func (d *InputMessageData) MockMessage() *MockMessage {
|
|||||||
msg := &MockMessage{}
|
msg := &MockMessage{}
|
||||||
msg.On("ID").Return(d.ID)
|
msg.On("ID").Return(d.ID)
|
||||||
msg.On("From").Return(d.From)
|
msg.On("From").Return(d.From)
|
||||||
|
msg.On("To").Return(d.To)
|
||||||
msg.On("Subject").Return(d.Subject)
|
msg.On("Subject").Return(d.Subject)
|
||||||
msg.On("Date").Return(d.Date)
|
msg.On("Date").Return(d.Date)
|
||||||
msg.On("Size").Return(d.Size)
|
msg.On("Size").Return(d.Size)
|
||||||
@@ -85,6 +89,10 @@ func (d *InputMessageData) CompareToJSONHeader(j *OutputJSONHeader) (errors []st
|
|||||||
errors = append(errors, fmt.Sprintf("Expected JSON.From=%q, got %q", d.From,
|
errors = append(errors, fmt.Sprintf("Expected JSON.From=%q, got %q", d.From,
|
||||||
j.From))
|
j.From))
|
||||||
}
|
}
|
||||||
|
if d.To != j.To {
|
||||||
|
errors = append(errors, fmt.Sprintf("Expected JSON.To=%q, got %q", d.To,
|
||||||
|
j.To))
|
||||||
|
}
|
||||||
if d.Subject != j.Subject {
|
if d.Subject != j.Subject {
|
||||||
errors = append(errors, fmt.Sprintf("Expected JSON.Subject=%q, got %q", d.Subject,
|
errors = append(errors, fmt.Sprintf("Expected JSON.Subject=%q, got %q", d.Subject,
|
||||||
j.Subject))
|
j.Subject))
|
||||||
@@ -115,6 +123,10 @@ func (d *InputMessageData) CompareToJSONMessage(j *OutputJSONMessage) (errors []
|
|||||||
errors = append(errors, fmt.Sprintf("Expected JSON.From=%q, got %q", d.From,
|
errors = append(errors, fmt.Sprintf("Expected JSON.From=%q, got %q", d.From,
|
||||||
j.From))
|
j.From))
|
||||||
}
|
}
|
||||||
|
if d.To != j.To {
|
||||||
|
errors = append(errors, fmt.Sprintf("Expected JSON.To=%q, got %q", d.To,
|
||||||
|
j.To))
|
||||||
|
}
|
||||||
if d.Subject != j.Subject {
|
if d.Subject != j.Subject {
|
||||||
errors = append(errors, fmt.Sprintf("Expected JSON.Subject=%q, got %q", d.Subject,
|
errors = append(errors, fmt.Sprintf("Expected JSON.Subject=%q, got %q", d.Subject,
|
||||||
j.Subject))
|
j.Subject))
|
||||||
@@ -225,6 +237,7 @@ func TestRestMailboxList(t *testing.T) {
|
|||||||
Mailbox: "good",
|
Mailbox: "good",
|
||||||
ID: "0001",
|
ID: "0001",
|
||||||
From: "from1",
|
From: "from1",
|
||||||
|
To: "to1",
|
||||||
Subject: "subject 1",
|
Subject: "subject 1",
|
||||||
Date: time.Date(2012, 2, 1, 10, 11, 12, 253, time.FixedZone("PST", -800)),
|
Date: time.Date(2012, 2, 1, 10, 11, 12, 253, time.FixedZone("PST", -800)),
|
||||||
}
|
}
|
||||||
@@ -232,6 +245,7 @@ func TestRestMailboxList(t *testing.T) {
|
|||||||
Mailbox: "good",
|
Mailbox: "good",
|
||||||
ID: "0002",
|
ID: "0002",
|
||||||
From: "from2",
|
From: "from2",
|
||||||
|
To: "to2",
|
||||||
Subject: "subject 2",
|
Subject: "subject 2",
|
||||||
Date: time.Date(2012, 7, 1, 10, 11, 12, 253, time.FixedZone("PDT", -700)),
|
Date: time.Date(2012, 7, 1, 10, 11, 12, 253, time.FixedZone("PDT", -700)),
|
||||||
}
|
}
|
||||||
@@ -345,6 +359,7 @@ func TestRestMessage(t *testing.T) {
|
|||||||
Mailbox: "good",
|
Mailbox: "good",
|
||||||
ID: "0001",
|
ID: "0001",
|
||||||
From: "from1",
|
From: "from1",
|
||||||
|
To: "to1",
|
||||||
Subject: "subject 1",
|
Subject: "subject 1",
|
||||||
Date: time.Date(2012, 2, 1, 10, 11, 12, 253, time.FixedZone("PST", -800)),
|
Date: time.Date(2012, 2, 1, 10, 11, 12, 253, time.FixedZone("PST", -800)),
|
||||||
Header: mail.Header{
|
Header: mail.Header{
|
||||||
@@ -478,6 +493,11 @@ func (m *MockMessage) From() string {
|
|||||||
return args.String(0)
|
return args.String(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MockMessage) To() string {
|
||||||
|
args := m.Called()
|
||||||
|
return args.String(0)
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MockMessage) Date() time.Time {
|
func (m *MockMessage) Date() time.Time {
|
||||||
args := m.Called()
|
args := m.Called()
|
||||||
return args.Get(0).(time.Time)
|
return args.Get(0).(time.Time)
|
||||||
|
|||||||
Reference in New Issue
Block a user