mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 01:57:02 +00:00
Move handler tests to shared datastore mocks for #48
This commit is contained in:
@@ -26,9 +26,7 @@ type scriptStep struct {
|
|||||||
// Test commands in GREET state
|
// Test commands in GREET state
|
||||||
func TestGreetState(t *testing.T) {
|
func TestGreetState(t *testing.T) {
|
||||||
// Setup mock objects
|
// Setup mock objects
|
||||||
mds := &MockDataStore{}
|
mds := &datastore.MockDataStore{}
|
||||||
mb1 := &MockMailbox{}
|
|
||||||
mds.On("MailboxFor").Return(mb1, nil)
|
|
||||||
|
|
||||||
server, logbuf, teardown := setupSMTPServer(mds)
|
server, logbuf, teardown := setupSMTPServer(mds)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
@@ -87,9 +85,7 @@ func TestGreetState(t *testing.T) {
|
|||||||
// Test commands in READY state
|
// Test commands in READY state
|
||||||
func TestReadyState(t *testing.T) {
|
func TestReadyState(t *testing.T) {
|
||||||
// Setup mock objects
|
// Setup mock objects
|
||||||
mds := &MockDataStore{}
|
mds := &datastore.MockDataStore{}
|
||||||
mb1 := &MockMailbox{}
|
|
||||||
mds.On("MailboxFor").Return(mb1, nil)
|
|
||||||
|
|
||||||
server, logbuf, teardown := setupSMTPServer(mds)
|
server, logbuf, teardown := setupSMTPServer(mds)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
@@ -152,10 +148,10 @@ func TestReadyState(t *testing.T) {
|
|||||||
// Test commands in MAIL state
|
// Test commands in MAIL state
|
||||||
func TestMailState(t *testing.T) {
|
func TestMailState(t *testing.T) {
|
||||||
// Setup mock objects
|
// Setup mock objects
|
||||||
mds := &MockDataStore{}
|
mds := &datastore.MockDataStore{}
|
||||||
mb1 := &MockMailbox{}
|
mb1 := &datastore.MockMailbox{}
|
||||||
msg1 := &MockMessage{}
|
msg1 := &datastore.MockMessage{}
|
||||||
mds.On("MailboxFor").Return(mb1, nil)
|
mds.On("MailboxFor", "u1").Return(mb1, nil)
|
||||||
mb1.On("NewMessage").Return(msg1, nil)
|
mb1.On("NewMessage").Return(msg1, nil)
|
||||||
mb1.On("Name").Return("u1")
|
mb1.On("Name").Return("u1")
|
||||||
msg1.On("ID").Return("")
|
msg1.On("ID").Return("")
|
||||||
@@ -269,10 +265,10 @@ func TestMailState(t *testing.T) {
|
|||||||
// Test commands in DATA state
|
// Test commands in DATA state
|
||||||
func TestDataState(t *testing.T) {
|
func TestDataState(t *testing.T) {
|
||||||
// Setup mock objects
|
// Setup mock objects
|
||||||
mds := &MockDataStore{}
|
mds := &datastore.MockDataStore{}
|
||||||
mb1 := &MockMailbox{}
|
mb1 := &datastore.MockMailbox{}
|
||||||
msg1 := &MockMessage{}
|
msg1 := &datastore.MockMessage{}
|
||||||
mds.On("MailboxFor").Return(mb1, nil)
|
mds.On("MailboxFor", "u1").Return(mb1, nil)
|
||||||
mb1.On("NewMessage").Return(msg1, nil)
|
mb1.On("NewMessage").Return(msg1, nil)
|
||||||
mb1.On("Name").Return("u1")
|
mb1.On("Name").Return("u1")
|
||||||
msg1.On("ID").Return("")
|
msg1.On("ID").Return("")
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ type MockDataStore struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockDataStore) MailboxFor(name string) (datastore.Mailbox, error) {
|
func (m *MockDataStore) MailboxFor(name string) (datastore.Mailbox, error) {
|
||||||
args := m.Called()
|
args := m.Called(name)
|
||||||
return args.Get(0).(datastore.Mailbox), args.Error(1)
|
return args.Get(0).(datastore.Mailbox), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user