testutil

package
v1.0.30 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package testutil provides test utilities including mock implementations of client interfaces for unit testing command handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SampleAttachment

func SampleAttachment(filename string) *gmailapi.Attachment

SampleAttachment returns a sample attachment for testing

func SampleCalendar

func SampleCalendar(id string, primary bool) *calendar.CalendarListEntry

SampleCalendar returns a sample calendar for testing

func SampleCalendars

func SampleCalendars() []*calendar.CalendarListEntry

SampleCalendars returns sample calendars for testing

func SampleContact

func SampleContact(resourceName string) *contactsapi.Contact

SampleContact returns a parsed contact for testing

func SampleContactGroup

func SampleContactGroup(resourceName string) *contactsapi.ContactGroup

SampleContactGroup returns a sample contact group for testing

func SampleDriveFile

func SampleDriveFile(id string) *driveapi.File

SampleDriveFile returns a sample Drive file for testing

func SampleDriveFiles

func SampleDriveFiles(count int) []*driveapi.File

SampleDriveFiles returns sample Drive files for testing

func SampleEvent

func SampleEvent(id string) *calendar.Event

SampleEvent returns a sample calendar event for testing

func SampleGoogleDoc

func SampleGoogleDoc(id string) *driveapi.File

SampleGoogleDoc returns a Google Doc file for testing export scenarios

func SampleLabels

func SampleLabels() []*gmail.Label

SampleLabels returns sample Gmail labels for testing

func SampleMessage

func SampleMessage(id string) *gmailapi.Message

SampleMessage returns a sample Gmail message for testing

func SampleMessages

func SampleMessages(count int) []*gmailapi.Message

SampleMessages returns a slice of sample messages

func SampleParsedEvent

func SampleParsedEvent(id string) *calendarapi.Event

SampleParsedEvent returns a parsed calendar event for testing

func SamplePerson

func SamplePerson(resourceName string) *people.Person

SamplePerson returns a sample Google People API Person for testing

func SampleProfile

func SampleProfile() *gmailapi.Profile

SampleProfile returns a sample Gmail profile for testing

Types

type MockCalendarClient

type MockCalendarClient struct {
	ListCalendarsFunc func() ([]*calendar.CalendarListEntry, error)
	ListEventsFunc    func(calendarID, timeMin, timeMax string, maxResults int64) ([]*calendar.Event, error)
	GetEventFunc      func(calendarID, eventID string) (*calendar.Event, error)
}

MockCalendarClient is a configurable mock for CalendarClientInterface.

func (*MockCalendarClient) GetEvent

func (m *MockCalendarClient) GetEvent(calendarID, eventID string) (*calendar.Event, error)

func (*MockCalendarClient) ListCalendars

func (m *MockCalendarClient) ListCalendars() ([]*calendar.CalendarListEntry, error)

func (*MockCalendarClient) ListEvents

func (m *MockCalendarClient) ListEvents(calendarID, timeMin, timeMax string, maxResults int64) ([]*calendar.Event, error)

type MockContactsClient

type MockContactsClient struct {
	ListContactsFunc      func(pageToken string, pageSize int64) (*people.ListConnectionsResponse, error)
	SearchContactsFunc    func(query string, pageSize int64) (*people.SearchResponse, error)
	GetContactFunc        func(resourceName string) (*people.Person, error)
	ListContactGroupsFunc func(pageToken string, pageSize int64) (*people.ListContactGroupsResponse, error)
}

MockContactsClient is a configurable mock for ContactsClientInterface.

func (*MockContactsClient) GetContact

func (m *MockContactsClient) GetContact(resourceName string) (*people.Person, error)

func (*MockContactsClient) ListContactGroups

func (m *MockContactsClient) ListContactGroups(pageToken string, pageSize int64) (*people.ListContactGroupsResponse, error)

func (*MockContactsClient) ListContacts

func (m *MockContactsClient) ListContacts(pageToken string, pageSize int64) (*people.ListConnectionsResponse, error)

func (*MockContactsClient) SearchContacts

func (m *MockContactsClient) SearchContacts(query string, pageSize int64) (*people.SearchResponse, error)

type MockDriveClient

type MockDriveClient struct {
	ListFilesFunc    func(query string, pageSize int64) ([]*driveapi.File, error)
	GetFileFunc      func(fileID string) (*driveapi.File, error)
	DownloadFileFunc func(fileID string) ([]byte, error)
	ExportFileFunc   func(fileID, mimeType string) ([]byte, error)
}

MockDriveClient is a configurable mock for DriveClientInterface.

func (*MockDriveClient) DownloadFile

func (m *MockDriveClient) DownloadFile(fileID string) ([]byte, error)

func (*MockDriveClient) ExportFile

func (m *MockDriveClient) ExportFile(fileID, mimeType string) ([]byte, error)

func (*MockDriveClient) GetFile

func (m *MockDriveClient) GetFile(fileID string) (*driveapi.File, error)

func (*MockDriveClient) ListFiles

func (m *MockDriveClient) ListFiles(query string, pageSize int64) ([]*driveapi.File, error)

type MockGmailClient

type MockGmailClient struct {
	GetMessageFunc               func(messageID string, includeBody bool) (*gmailapi.Message, error)
	SearchMessagesFunc           func(query string, maxResults int64) ([]*gmailapi.Message, int, error)
	GetThreadFunc                func(id string) ([]*gmailapi.Message, error)
	FetchLabelsFunc              func() error
	GetLabelNameFunc             func(labelID string) string
	GetLabelsFunc                func() []*gmail.Label
	GetAttachmentsFunc           func(messageID string) ([]*gmailapi.Attachment, error)
	DownloadAttachmentFunc       func(messageID, attachmentID string) ([]byte, error)
	DownloadInlineAttachmentFunc func(messageID, partID string) ([]byte, error)
	GetProfileFunc               func() (*gmailapi.Profile, error)
}

MockGmailClient is a configurable mock for GmailClientInterface. Set the function fields to control behavior in tests.

func (*MockGmailClient) DownloadAttachment

func (m *MockGmailClient) DownloadAttachment(messageID, attachmentID string) ([]byte, error)

func (*MockGmailClient) DownloadInlineAttachment

func (m *MockGmailClient) DownloadInlineAttachment(messageID, partID string) ([]byte, error)

func (*MockGmailClient) FetchLabels

func (m *MockGmailClient) FetchLabels() error

func (*MockGmailClient) GetAttachments

func (m *MockGmailClient) GetAttachments(messageID string) ([]*gmailapi.Attachment, error)

func (*MockGmailClient) GetLabelName

func (m *MockGmailClient) GetLabelName(labelID string) string

func (*MockGmailClient) GetLabels

func (m *MockGmailClient) GetLabels() []*gmail.Label

func (*MockGmailClient) GetMessage

func (m *MockGmailClient) GetMessage(messageID string, includeBody bool) (*gmailapi.Message, error)

func (*MockGmailClient) GetProfile

func (m *MockGmailClient) GetProfile() (*gmailapi.Profile, error)

func (*MockGmailClient) GetThread

func (m *MockGmailClient) GetThread(id string) ([]*gmailapi.Message, error)

func (*MockGmailClient) SearchMessages

func (m *MockGmailClient) SearchMessages(query string, maxResults int64) ([]*gmailapi.Message, int, error)

Jump to

Keyboard shortcuts

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