Documentation
¶
Overview ¶
Package testutil provides test utilities including mock implementations of client interfaces for unit testing command handlers.
Index ¶
- func SampleAttachment(filename string) *gmailapi.Attachment
- func SampleCalendar(id string, primary bool) *calendar.CalendarListEntry
- func SampleCalendars() []*calendar.CalendarListEntry
- func SampleContact(resourceName string) *contactsapi.Contact
- func SampleContactGroup(resourceName string) *contactsapi.ContactGroup
- func SampleDriveFile(id string) *driveapi.File
- func SampleDriveFiles(count int) []*driveapi.File
- func SampleEvent(id string) *calendar.Event
- func SampleGoogleDoc(id string) *driveapi.File
- func SampleLabels() []*gmail.Label
- func SampleMessage(id string) *gmailapi.Message
- func SampleMessages(count int) []*gmailapi.Message
- func SampleParsedEvent(id string) *calendarapi.Event
- func SamplePerson(resourceName string) *people.Person
- func SampleProfile() *gmailapi.Profile
- func SampleSharedDrive(id, name string) *driveapi.SharedDrive
- func SampleSharedDriveFile(id, driveID string) *driveapi.File
- func SampleSharedDrives() []*driveapi.SharedDrive
- type MockCalendarClient
- type MockContactsClient
- func (m *MockContactsClient) GetContact(resourceName string) (*people.Person, error)
- func (m *MockContactsClient) ListContactGroups(pageToken string, pageSize int64) (*people.ListContactGroupsResponse, error)
- func (m *MockContactsClient) ListContacts(pageToken string, pageSize int64) (*people.ListConnectionsResponse, error)
- func (m *MockContactsClient) SearchContacts(query string, pageSize int64) (*people.SearchResponse, error)
- type MockDriveClient
- func (m *MockDriveClient) DownloadFile(fileID string) ([]byte, error)
- func (m *MockDriveClient) ExportFile(fileID, mimeType string) ([]byte, error)
- func (m *MockDriveClient) GetFile(fileID string) (*driveapi.File, error)
- func (m *MockDriveClient) ListFiles(query string, pageSize int64) ([]*driveapi.File, error)
- func (m *MockDriveClient) ListFilesWithScope(query string, pageSize int64, scope driveapi.DriveScope) ([]*driveapi.File, error)
- func (m *MockDriveClient) ListSharedDrives(pageSize int64) ([]*driveapi.SharedDrive, error)
- type MockGmailClient
- func (m *MockGmailClient) DownloadAttachment(messageID, attachmentID string) ([]byte, error)
- func (m *MockGmailClient) DownloadInlineAttachment(messageID, partID string) ([]byte, error)
- func (m *MockGmailClient) FetchLabels() error
- func (m *MockGmailClient) GetAttachments(messageID string) ([]*gmailapi.Attachment, error)
- func (m *MockGmailClient) GetLabelName(labelID string) string
- func (m *MockGmailClient) GetLabels() []*gmail.Label
- func (m *MockGmailClient) GetMessage(messageID string, includeBody bool) (*gmailapi.Message, error)
- func (m *MockGmailClient) GetProfile() (*gmailapi.Profile, error)
- func (m *MockGmailClient) GetThread(id string) ([]*gmailapi.Message, error)
- func (m *MockGmailClient) SearchMessages(query string, maxResults int64) ([]*gmailapi.Message, int, error)
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 ¶
SampleDriveFile returns a sample Drive file for testing
func SampleDriveFiles ¶
SampleDriveFiles returns sample Drive files for testing
func SampleEvent ¶
SampleEvent returns a sample calendar event for testing
func SampleGoogleDoc ¶
SampleGoogleDoc returns a Google Doc file for testing export scenarios
func SampleLabels ¶
SampleLabels returns sample Gmail labels for testing
func SampleMessage ¶
SampleMessage returns a sample Gmail message for testing
func SampleMessages ¶
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 ¶
SamplePerson returns a sample Google People API Person for testing
func SampleProfile ¶
SampleProfile returns a sample Gmail profile for testing
func SampleSharedDrive ¶ added in v1.0.32
func SampleSharedDrive(id, name string) *driveapi.SharedDrive
SampleSharedDrive returns a sample shared drive for testing
func SampleSharedDriveFile ¶ added in v1.0.32
SampleSharedDriveFile returns a file that belongs to a shared drive
func SampleSharedDrives ¶ added in v1.0.32
func SampleSharedDrives() []*driveapi.SharedDrive
SampleSharedDrives returns a set of sample shared drives 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 ¶
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)
ListFilesWithScopeFunc func(query string, pageSize int64, scope driveapi.DriveScope) ([]*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) ListFilesWithScope ¶ added in v1.0.32
func (m *MockDriveClient) ListFilesWithScope(query string, pageSize int64, scope driveapi.DriveScope) ([]*driveapi.File, error)
func (*MockDriveClient) ListSharedDrives ¶ added in v1.0.32
func (m *MockDriveClient) ListSharedDrives(pageSize int64) ([]*driveapi.SharedDrive, 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 (*MockGmailClient) GetProfile ¶
func (m *MockGmailClient) GetProfile() (*gmailapi.Profile, error)
func (*MockGmailClient) GetThread ¶
func (m *MockGmailClient) GetThread(id string) ([]*gmailapi.Message, error)