storetest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package storetest provides a StoreFixture and helpers for tests that exercise the Store layer through its public API.

Index

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

func New(t *testing.T) *Fixture

New creates a Fixture with a fresh test database, one source ("test@example.com") and one default conversation.

func (*Fixture) AssertActiveSync

func (f *Fixture) AssertActiveSync(wantID int64, wantStatus string)

AssertActiveSync asserts there is an active sync with the given ID and status.

func (*Fixture) AssertLabelCount

func (f *Fixture) AssertLabelCount(msgID int64, want int)

AssertLabelCount asserts the number of labels attached to a message.

func (*Fixture) AssertMessageDeleted

func (f *Fixture) AssertMessageDeleted(msgID int64)

AssertMessageDeleted asserts that a message has been marked as deleted.

func (*Fixture) AssertMessageNotDeleted

func (f *Fixture) AssertMessageNotDeleted(msgID int64)

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

func (f *Fixture) AssertRecipientCount(msgID int64, typ string, want int)

AssertRecipientCount asserts the number of recipients of a given type for a message.

func (*Fixture) CreateMessage

func (f *Fixture) CreateMessage(sourceMessageID string) int64

CreateMessage inserts a minimal message and returns its internal ID.

func (*Fixture) CreateMessages

func (f *Fixture) CreateMessages(count int) []int64

CreateMessages inserts count messages with IDs "msg-0" .. "msg-(count-1)".

func (*Fixture) EnsureLabels

func (f *Fixture) EnsureLabels(labels map[string]string, typ string) map[string]int64

EnsureLabels creates labels and returns a map of sourceLabelID → internal ID.

func (*Fixture) EnsureParticipant

func (f *Fixture) EnsureParticipant(email, name, domain string) int64

EnsureParticipant creates or gets a participant and returns its 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.

func (*Fixture) StartSync

func (f *Fixture) StartSync() int64

StartSync starts a sync run and returns its ID.

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

func (b *MessageBuilder) Create(t *testing.T, st *store.Store) int64

Create inserts the message into the store and returns its internal ID.

func (*MessageBuilder) WithAttachments

func (b *MessageBuilder) WithAttachments(count int) *MessageBuilder

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

Jump to

Keyboard shortcuts

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