Documentation
¶
Overview ¶
Package storetest provides a StoreFixture and helpers for tests that exercise the Store layer through its public API.
Index ¶
- type Fixture
- func (f *Fixture) AssertActiveSync(wantID int64, wantStatus string)
- func (f *Fixture) AssertLabelCount(msgID int64, want int)
- func (f *Fixture) AssertMessageDeleted(msgID int64)
- func (f *Fixture) AssertMessageNotDeleted(msgID int64)
- func (f *Fixture) AssertNoActiveSync()
- func (f *Fixture) AssertRecipientCount(msgID int64, typ string, want int)
- func (f *Fixture) CreateMessage(sourceMessageID string) int64
- func (f *Fixture) CreateMessages(count int) []int64
- func (f *Fixture) EnsureLabels(labels map[string]string, typ string) map[string]int64
- func (f *Fixture) EnsureParticipant(email, name, domain string) int64
- func (f *Fixture) GetMessageBody(msgID int64) (sql.NullString, sql.NullString)
- func (f *Fixture) GetMessageFields(msgID int64) MessageFields
- func (f *Fixture) GetSingleLabelID(msgID int64) int64
- func (f *Fixture) GetSingleRecipientID(msgID int64, typ string) int64
- func (f *Fixture) GetSyncRun(syncID int64) (status, errorMsg string)
- func (f *Fixture) NewMessage() *MessageBuilder
- func (f *Fixture) StartSync() int64
- type MessageBuilder
- func (b *MessageBuilder) Build() *store.Message
- func (b *MessageBuilder) Create(t *testing.T, st *store.Store) int64
- func (b *MessageBuilder) WithAttachmentCount(count int) *MessageBuilder
- func (b *MessageBuilder) WithInternalDate(t time.Time) *MessageBuilder
- func (b *MessageBuilder) WithIsFromMe(v bool) *MessageBuilder
- func (b *MessageBuilder) WithReceivedAt(t time.Time) *MessageBuilder
- func (b *MessageBuilder) WithSentAt(t time.Time) *MessageBuilder
- func (b *MessageBuilder) WithSize(n int64) *MessageBuilder
- func (b *MessageBuilder) WithSnippet(s string) *MessageBuilder
- func (b *MessageBuilder) WithSourceMessageID(id string) *MessageBuilder
- func (b *MessageBuilder) WithSubject(s string) *MessageBuilder
- type MessageFields
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fixture ¶
type Fixture struct {
T *testing.T
Store *store.Store
Source *store.Source
ConvID int64
// contains filtered or unexported fields
}
Fixture holds common test state for store-level tests.
func New ¶
New creates a Fixture with a fresh test database, one source ("test@example.com") and one default conversation.
func (*Fixture) AssertActiveSync ¶
AssertActiveSync asserts there is an active sync with the given ID and status.
func (*Fixture) AssertLabelCount ¶
AssertLabelCount asserts the number of labels attached to a message.
func (*Fixture) AssertMessageDeleted ¶
AssertMessageDeleted asserts that a message has been marked as deleted.
func (*Fixture) AssertMessageNotDeleted ¶
AssertMessageNotDeleted asserts that a message has NOT been marked as deleted.
func (*Fixture) AssertNoActiveSync ¶
func (f *Fixture) AssertNoActiveSync()
AssertNoActiveSync asserts there is no active sync for the fixture's source.
func (*Fixture) AssertRecipientCount ¶
AssertRecipientCount asserts the number of recipients of a given type for a message.
func (*Fixture) CreateMessage ¶
CreateMessage inserts a minimal message and returns its internal ID.
func (*Fixture) CreateMessages ¶
CreateMessages inserts count messages with IDs "msg-0" .. "msg-(count-1)".
func (*Fixture) EnsureLabels ¶
EnsureLabels creates labels and returns a map of sourceLabelID → internal ID.
func (*Fixture) EnsureParticipant ¶
EnsureParticipant creates or gets a participant and returns its ID.
func (*Fixture) GetMessageBody ¶ added in v0.4.0
func (f *Fixture) GetMessageBody(msgID int64) (sql.NullString, sql.NullString)
GetMessageBody returns the body_text and body_html for a message.
func (*Fixture) GetMessageFields ¶ added in v0.4.0
func (f *Fixture) GetMessageFields(msgID int64) MessageFields
GetMessageFields returns selected fields of a message by ID.
func (*Fixture) GetSingleLabelID ¶ added in v0.4.0
GetSingleLabelID returns the label_id for a message that should have exactly one label.
func (*Fixture) GetSingleRecipientID ¶ added in v0.4.0
GetSingleRecipientID returns the participant_id for a message+type that should have exactly one recipient.
func (*Fixture) GetSyncRun ¶ added in v0.4.0
GetSyncRun returns the status and error_message for a sync run by ID.
func (*Fixture) NewMessage ¶
func (f *Fixture) NewMessage() *MessageBuilder
NewMessage creates a builder using the fixture's per-test counter for deterministic SourceMessageID values (fixture-msg-1, fixture-msg-2, ...). Uses a distinct prefix from the package-level NewMessage to avoid collisions.
type MessageBuilder ¶
type MessageBuilder struct {
// contains filtered or unexported fields
}
MessageBuilder provides a fluent API for constructing store.Message values.
func NewMessage ¶
func NewMessage(sourceID, convID int64) *MessageBuilder
NewMessage creates a builder with sensible defaults. NewMessage creates a builder with sensible defaults. It uses a global counter to generate unique SourceMessageID values; prefer Fixture.NewMessage for per-test deterministic IDs.
func (*MessageBuilder) Build ¶
func (b *MessageBuilder) Build() *store.Message
Build returns the constructed Message.
func (*MessageBuilder) Create ¶
Create inserts the message into the store and returns its internal ID.
func (*MessageBuilder) WithAttachmentCount ¶ added in v0.4.0
func (b *MessageBuilder) WithAttachmentCount(count int) *MessageBuilder
WithAttachmentCount sets the attachment count and HasAttachments flag.
func (*MessageBuilder) WithInternalDate ¶
func (b *MessageBuilder) WithInternalDate(t time.Time) *MessageBuilder
func (*MessageBuilder) WithIsFromMe ¶
func (b *MessageBuilder) WithIsFromMe(v bool) *MessageBuilder
func (*MessageBuilder) WithReceivedAt ¶
func (b *MessageBuilder) WithReceivedAt(t time.Time) *MessageBuilder
func (*MessageBuilder) WithSentAt ¶
func (b *MessageBuilder) WithSentAt(t time.Time) *MessageBuilder
func (*MessageBuilder) WithSize ¶
func (b *MessageBuilder) WithSize(n int64) *MessageBuilder
func (*MessageBuilder) WithSnippet ¶
func (b *MessageBuilder) WithSnippet(s string) *MessageBuilder
func (*MessageBuilder) WithSourceMessageID ¶
func (b *MessageBuilder) WithSourceMessageID(id string) *MessageBuilder
func (*MessageBuilder) WithSubject ¶
func (b *MessageBuilder) WithSubject(s string) *MessageBuilder
type MessageFields ¶ added in v0.4.0
MessageFields holds a subset of message columns for test verification.