querytest

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: 4 Imported by: 0

Documentation

Overview

Package querytest provides shared test doubles for the query.Engine interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockEngine

type MockEngine struct {
	SearchFastResults []query.MessageSummary
	SearchResults     []query.MessageSummary
	ListResults       []query.MessageSummary
	Messages          map[int64]*query.MessageDetail
	Attachments       map[int64]*query.AttachmentInfo
	Stats             *query.TotalStats
	Accounts          []query.AccountInfo
	AggregateRows     []query.AggregateRow
	GmailIDs          []string

	// MessagesBySourceID maps source IDs to message details for GetMessageBySourceID.
	// When nil, GetMessageBySourceID falls back to scanning Messages for a matching SourceMessageID.
	MessagesBySourceID map[string]*query.MessageDetail

	// Optional overrides — set these to customise behavior per-test.
	SearchFastFunc           func(context.Context, *search.Query, query.MessageFilter, int, int) ([]query.MessageSummary, error)
	SearchFunc               func(context.Context, *search.Query, int, int) ([]query.MessageSummary, error)
	GetMessageFunc           func(context.Context, int64) (*query.MessageDetail, error)
	GetMessageBySourceIDFunc func(context.Context, string) (*query.MessageDetail, error)
	GetTotalStatsFunc        func(context.Context, query.StatsOptions) (*query.TotalStats, error)
	ListMessagesFunc         func(context.Context, query.MessageFilter) ([]query.MessageSummary, error)
	SearchFastCountFunc      func(context.Context, *search.Query, query.MessageFilter) (int64, error)
}

MockEngine implements query.Engine for testing. Each method delegates to an optional function field; when the field is nil, a safe zero value is returned.

func (*MockEngine) AggregateByDomain

func (m *MockEngine) AggregateByDomain(_ context.Context, _ query.AggregateOptions) ([]query.AggregateRow, error)

func (*MockEngine) AggregateByLabel

func (m *MockEngine) AggregateByLabel(_ context.Context, _ query.AggregateOptions) ([]query.AggregateRow, error)

func (*MockEngine) AggregateByRecipient

func (m *MockEngine) AggregateByRecipient(_ context.Context, _ query.AggregateOptions) ([]query.AggregateRow, error)

func (*MockEngine) AggregateByRecipientName

func (m *MockEngine) AggregateByRecipientName(_ context.Context, _ query.AggregateOptions) ([]query.AggregateRow, error)

func (*MockEngine) AggregateBySender

func (m *MockEngine) AggregateBySender(_ context.Context, _ query.AggregateOptions) ([]query.AggregateRow, error)

func (*MockEngine) AggregateBySenderName

func (m *MockEngine) AggregateBySenderName(_ context.Context, _ query.AggregateOptions) ([]query.AggregateRow, error)

func (*MockEngine) AggregateByTime

func (m *MockEngine) AggregateByTime(_ context.Context, _ query.AggregateOptions) ([]query.AggregateRow, error)

func (*MockEngine) Close

func (m *MockEngine) Close() error

func (*MockEngine) GetAttachment

func (m *MockEngine) GetAttachment(_ context.Context, id int64) (*query.AttachmentInfo, error)

func (*MockEngine) GetGmailIDsByFilter

func (m *MockEngine) GetGmailIDsByFilter(_ context.Context, _ query.MessageFilter) ([]string, error)

func (*MockEngine) GetMessage

func (m *MockEngine) GetMessage(ctx context.Context, id int64) (*query.MessageDetail, error)

func (*MockEngine) GetMessageBySourceID

func (m *MockEngine) GetMessageBySourceID(ctx context.Context, sourceID string) (*query.MessageDetail, error)

func (*MockEngine) GetTotalStats

func (m *MockEngine) GetTotalStats(ctx context.Context, opts query.StatsOptions) (*query.TotalStats, error)

func (*MockEngine) ListAccounts

func (m *MockEngine) ListAccounts(_ context.Context) ([]query.AccountInfo, error)

func (*MockEngine) ListMessages

func (m *MockEngine) ListMessages(ctx context.Context, filter query.MessageFilter) ([]query.MessageSummary, error)

func (*MockEngine) Search

func (m *MockEngine) Search(ctx context.Context, q *search.Query, limit, offset int) ([]query.MessageSummary, error)

func (*MockEngine) SearchFast

func (m *MockEngine) SearchFast(ctx context.Context, q *search.Query, filter query.MessageFilter, limit, offset int) ([]query.MessageSummary, error)

func (*MockEngine) SearchFastCount

func (m *MockEngine) SearchFastCount(ctx context.Context, q *search.Query, filter query.MessageFilter) (int64, error)

Jump to

Keyboard shortcuts

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