1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-19 18:47:03 +00:00

storage: More refactoring for #69

- impl Store.AddMessage
- file: Use AddMessage() in tests
- smtp: Switch to AddMessage
- storage: Remove NewMessage, Append, Close methods
This commit is contained in:
James Hillyerd
2018-03-13 22:00:44 -07:00
parent 9be4eec31c
commit 2cc0da3093
10 changed files with 208 additions and 208 deletions

View File

@@ -23,9 +23,11 @@ func NewStore() *StoreStub {
}
// AddMessage adds a message to the specified mailbox.
func (s *StoreStub) AddMessage(mailbox string, m storage.StoreMessage) {
msgs := s.mailboxes[mailbox]
s.mailboxes[mailbox] = append(msgs, m)
func (s *StoreStub) AddMessage(m storage.StoreMessage) (id string, err error) {
mb := m.Mailbox()
msgs := s.mailboxes[mb]
s.mailboxes[mb] = append(msgs, m)
return m.ID(), nil
}
// GetMessage gets a message by ID from the specified mailbox.
@@ -80,11 +82,6 @@ func (s *StoreStub) VisitMailboxes(f func([]storage.StoreMessage) (cont bool)) e
return nil
}
// NewMessage is temproary until #69 MessageData refactor
func (s *StoreStub) NewMessage(mailbox string) (storage.StoreMessage, error) {
return nil, nil
}
// LockFor mock function returns a new RWMutex, never errors.
// TODO(#69) remove
func (s *StoreStub) LockFor(name string) (*sync.RWMutex, error) {