Documentation
¶
Index ¶
- func NewTestDB(t *testing.T) *pgxpool.Pool
- func RunMigrations(ctx context.Context, pool *pgxpool.Pool) error
- type MemoryBackend
- type TestIMAPServer
- func (s *TestIMAPServer) AddMessage(t *testing.T, folderName, messageID, subject, from, to string, ...) uint32
- func (s *TestIMAPServer) AddMessageForE2E(folderName, messageID, subject, from, to string, sentAt time.Time) (uint32, error)
- func (s *TestIMAPServer) Close()
- func (s *TestIMAPServer) Connect(t *testing.T) (*imapclient.Client, func())
- func (s *TestIMAPServer) ConnectForE2E() (*imapclient.Client, error)
- func (s *TestIMAPServer) CreateFolderWithSpecialUse(folderName string) error
- func (s *TestIMAPServer) EnsureINBOX(t *testing.T)
- func (s *TestIMAPServer) EnsureINBOXForE2E() error
- func (s *TestIMAPServer) Password() string
- func (s *TestIMAPServer) Username() string
- type TestSMTPServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MemoryBackend ¶
type MemoryBackend struct {
// contains filtered or unexported fields
}
MemoryBackend is a simple in-memory SMTP backend for testing.
func NewMemoryBackend ¶
func NewMemoryBackend() *MemoryBackend
NewMemoryBackend creates a new in-memory SMTP backend.
func (*MemoryBackend) ClearMessages ¶
func (b *MemoryBackend) ClearMessages()
ClearMessages clears all stored messages.
func (*MemoryBackend) GetMessages ¶
func (b *MemoryBackend) GetMessages() []*memoryMessage
GetMessages returns all received messages.
func (*MemoryBackend) NewSession ¶
func (b *MemoryBackend) NewSession(*smtp.Conn) (smtp.Session, error)
NewSession creates a new SMTP session.
type TestIMAPServer ¶
type TestIMAPServer struct {
Server *server.Server
Address string
Backend *memory.Backend
// contains filtered or unexported fields
}
TestIMAPServer represents a test IMAP server instance.
func NewTestIMAPServer ¶
func NewTestIMAPServer(t *testing.T) *TestIMAPServer
NewTestIMAPServer creates a new test IMAP server with an in-memory backend. Returns the server instance and cleanup function. The memory backend creates a default user with username "username" and password "password".
Note: This function is intended for use in test files (requires *testing.T). For E2E tests that don't have a testing context, use NewTestIMAPServerForE2E instead.
func NewTestIMAPServerForE2E ¶
func NewTestIMAPServerForE2E() (*TestIMAPServer, error)
NewTestIMAPServerForE2E creates a new test IMAP server for E2E tests (non-test context). Returns the server instance. The memory backend creates a default user with username "username" and password "password". Uses a fixed port (1143) for E2E tests so Playwright can connect to it. The server includes SPECIAL-USE support for folder role detection.
func (*TestIMAPServer) AddMessage ¶
func (s *TestIMAPServer) AddMessage(t *testing.T, folderName, messageID, subject, from, to string, sentAt time.Time) uint32
AddMessage adds a test message to the specified folder and returns its UID.
func (*TestIMAPServer) AddMessageForE2E ¶
func (s *TestIMAPServer) AddMessageForE2E(folderName, messageID, subject, from, to string, sentAt time.Time) (uint32, error)
AddMessageForE2E adds a test message to the specified folder and returns its UID (non-test context).
func (*TestIMAPServer) Close ¶
func (s *TestIMAPServer) Close()
Close shuts down the test IMAP server.
func (*TestIMAPServer) Connect ¶
func (s *TestIMAPServer) Connect(t *testing.T) (*imapclient.Client, func())
Connect creates a new IMAP client connection to the test server.
func (*TestIMAPServer) ConnectForE2E ¶
func (s *TestIMAPServer) ConnectForE2E() (*imapclient.Client, error)
ConnectForE2E creates a new IMAP client connection to the test server (non-test context).
func (*TestIMAPServer) CreateFolderWithSpecialUse ¶
func (s *TestIMAPServer) CreateFolderWithSpecialUse(folderName string) error
CreateFolderWithSpecialUse creates a folder with SPECIAL-USE attributes (non-test context).
func (*TestIMAPServer) EnsureINBOX ¶
func (s *TestIMAPServer) EnsureINBOX(t *testing.T)
EnsureINBOX ensures the INBOX folder exists for the default user.
func (*TestIMAPServer) EnsureINBOXForE2E ¶
func (s *TestIMAPServer) EnsureINBOXForE2E() error
EnsureINBOXForE2E ensures the INBOX folder exists for the default user (non-test context).
func (*TestIMAPServer) Password ¶
func (s *TestIMAPServer) Password() string
Password returns the default test password.
func (*TestIMAPServer) Username ¶
func (s *TestIMAPServer) Username() string
Username returns the default test username.
type TestSMTPServer ¶
type TestSMTPServer struct {
Server *smtp.Server
Address string
Backend *MemoryBackend
// contains filtered or unexported fields
}
TestSMTPServer represents a test SMTP server instance.
func NewTestSMTPServer ¶
func NewTestSMTPServer(t *testing.T) *TestSMTPServer
NewTestSMTPServer creates a new test SMTP server with an in-memory backend. Returns the server instance. The memory backend accepts any username/password combination for testing.
func NewTestSMTPServerForE2E ¶
func NewTestSMTPServerForE2E() (*TestSMTPServer, error)
NewTestSMTPServerForE2E creates a new test SMTP server for E2E tests (non-test context). Returns the server instance. The memory backend accepts any username/password combination. Uses a fixed port (1025) for E2E tests so Playwright can connect to it.
func (*TestSMTPServer) ClearMessages ¶
func (s *TestSMTPServer) ClearMessages()
ClearMessages clears all stored messages.
func (*TestSMTPServer) Close ¶
func (s *TestSMTPServer) Close()
Close shuts down the test SMTP server.
func (*TestSMTPServer) GetMessages ¶
func (s *TestSMTPServer) GetMessages() []*memoryMessage
GetMessages returns all messages received by the server.
func (*TestSMTPServer) Password ¶
func (s *TestSMTPServer) Password() string
Password returns the test password.
func (*TestSMTPServer) Username ¶
func (s *TestSMTPServer) Username() string
Username returns the test username.