Documentation
¶
Overview ¶
Package gmailapitest is an in-process fake Gmail REST API v1 server for backend contract tests and coretest end-to-end tests, with zero external network dependency.
Index ¶
- type Delivery
- type Server
- func (s *Server) Accepted() []Delivery
- func (s *Server) AddMessage(raw []byte, labelNamesOrIDs ...string) string
- func (s *Server) DeleteLabel(id string)
- func (s *Server) DeleteMessage(msgID string)
- func (s *Server) Deliver(folder string, raw []byte) string
- func (s *Server) EnsureLabel(name string) string
- func (s *Server) ExpireHistory()
- func (s *Server) HostPort() (string, int)
- func (s *Server) ListMessageRequests() int
- func (s *Server) LoseVerdict()
- func (s *Server) MaxInFlight() int
- func (s *Server) MessageLabels(msgID string) []string
- func (s *Server) ModifyLabels(msgID string, add, remove []string)
- func (s *Server) Refuse(rcpt string)
- func (s *Server) RejectAuth()
- func (s *Server) RenameLabel(id, newName string)
- func (s *Server) SetAPIDisabled(disabled bool)
- func (s *Server) SetEmail(email string)
- func (s *Server) SetPageLimit(n int)
- func (s *Server) SetTokenValidator(fn func(string) bool)
- func (s *Server) ThrottleNext(n, status int, retryAfter string)
- func (s *Server) Token() string
- func (s *Server) URL() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an in-process fake Gmail REST API v1 server for one account.
func (*Server) AddMessage ¶
AddMessage adds a message with the given label names or IDs (such as "INBOX", "UNREAD", "Work") and returns its Gmail message ID.
func (*Server) DeleteLabel ¶
DeleteLabel deletes a user label and removes it from all messages.
func (*Server) DeleteMessage ¶
DeleteMessage permanently deletes msgID on the server, recording messagesDeleted.
func (*Server) Deliver ¶
Deliver delivers raw as a new unread message into folder (creating a user label if needed).
func (*Server) EnsureLabel ¶
EnsureLabel returns the label ID for name, creating a user label if needed.
func (*Server) ExpireHistory ¶
func (s *Server) ExpireHistory()
ExpireHistory invalidates all historyIds issued so far so history.list returns 404.
func (*Server) ListMessageRequests ¶
ListMessageRequests returns how many messages.list HTTP calls the server handled.
func (*Server) LoseVerdict ¶
func (s *Server) LoseVerdict()
LoseVerdict makes the next messages.send drop the TCP connection after reading the body.
func (*Server) MaxInFlight ¶
MaxInFlight returns the peak concurrent requests observed by the server.
func (*Server) MessageLabels ¶
MessageLabels returns a copy of msgID's current label IDs, or nil if deleted.
func (*Server) ModifyLabels ¶
ModifyLabels adds and removes labels (by name or ID) on msgID, as webmail would.
func (*Server) RejectAuth ¶
func (s *Server) RejectAuth()
RejectAuth makes every request fail with 401 Unauthorized.
func (*Server) RenameLabel ¶
RenameLabel renames an existing user label while preserving its ID.
func (*Server) SetAPIDisabled ¶
SetAPIDisabled makes every request fail with 403 accessNotConfigured.
func (*Server) SetPageLimit ¶
SetPageLimit caps list/history page sizes to test pagination.
func (*Server) SetTokenValidator ¶
SetTokenValidator sets a custom Bearer token check (such as testoauth's).
func (*Server) ThrottleNext ¶
ThrottleNext makes the next n authenticated requests return status (429 or 403 rateLimitExceeded) with optional Retry-After header before succeeding.
func (*Server) URL ¶
URL is the server's base URL (http://127.0.0.1:port).