test

package
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeliverToStore

func DeliverToStore(
	t *testing.T,
	store storage.Store,
	mailbox string,
	subject string,
	date time.Time,
) (string, int64)

DeliverToStore creates and delivers a message to the specific mailbox, returning the size of the generated message.

func GetAndCountMessages

func GetAndCountMessages(t *testing.T, s storage.Store, mailbox string, count int) []storage.Message

GetAndCountMessages is a test helper that expects to receive count messages or fails the test, it also checks return error.

func StoreSuite

func StoreSuite(t *testing.T, factory StoreFactory)

StoreSuite runs a set of general tests on the provided Store.

Types

type ManagerStub

type ManagerStub struct {
	message.Manager
	// contains filtered or unexported fields
}

ManagerStub is a test stub for message.Manager

func NewManager

func NewManager() *ManagerStub

NewManager creates a new ManagerStub.

func (*ManagerStub) AddMessage

func (m *ManagerStub) AddMessage(mailbox string, msg *message.Message)

AddMessage adds a message to the specified mailbox.

func (*ManagerStub) GetMessage

func (m *ManagerStub) GetMessage(mailbox, id string) (*message.Message, error)

GetMessage gets a message by ID from the specified mailbox.

func (*ManagerStub) GetMetadata

func (m *ManagerStub) GetMetadata(mailbox string) ([]*message.Metadata, error)

GetMetadata gets all the metadata for the specified mailbox.

func (*ManagerStub) MailboxForAddress

func (m *ManagerStub) MailboxForAddress(address string) (string, error)

MailboxForAddress invokes policy.ParseMailboxName.

func (*ManagerStub) MarkSeen

func (m *ManagerStub) MarkSeen(mailbox, id string) error

MarkSeen marks a message as having been read.

type StoreFactory

type StoreFactory func(config.Storage) (store storage.Store, destroy func(), err error)

StoreFactory returns a new store for the test suite.

type StoreStub

type StoreStub struct {
	storage.Store
	// contains filtered or unexported fields
}

StoreStub stubs storage.Store for testing.

func NewStore

func NewStore() *StoreStub

NewStore creates a new StoreStub.

func (*StoreStub) AddMessage

func (s *StoreStub) AddMessage(m storage.Message) (id string, err error)

AddMessage adds a message to the specified mailbox.

func (*StoreStub) GetMessage

func (s *StoreStub) GetMessage(mailbox, id string) (storage.Message, error)

GetMessage gets a message by ID from the specified mailbox.

func (*StoreStub) GetMessages

func (s *StoreStub) GetMessages(mailbox string) ([]storage.Message, error)

GetMessages gets all the messages for the specified mailbox.

func (*StoreStub) MessageDeleted

func (s *StoreStub) MessageDeleted(m storage.Message) bool

MessageDeleted returns true if the specified message was deleted

func (*StoreStub) RemoveMessage

func (s *StoreStub) RemoveMessage(mailbox, id string) error

RemoveMessage deletes a message by ID from the specified mailbox.

func (*StoreStub) VisitMailboxes

func (s *StoreStub) VisitMailboxes(f func([]storage.Message) (cont bool)) error

VisitMailboxes accepts a function that will be called with the messages in each mailbox while it continues to return true.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL