testutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const TestHMACSecret = "test-hmac-secret-for-testing"

Variables

This section is empty.

Functions

func OpenPreparedTestDB

func OpenPreparedTestDB(ctx context.Context, dbURL string) (*pgxpool.Pool, error)

func TestDB

func TestDB(t *testing.T) *pgxpool.Pool

func TestDBURL

func TestDBURL() string

func TruncateAll

func TruncateAll(t *testing.T, pool *pgxpool.Pool)

Types

type ContractServer

type ContractServer struct {
	BaseURL  string
	APIKey   string
	UserID   string
	DBPool   *pgxpool.Pool
	Store    *identity.Store
	WSHub    *ws.Hub
	Signer   *headers.Signer
	SMTPAddr string
	// contains filtered or unexported fields
}

func StartContractServer

func StartContractServer(ctx context.Context, dbURL string) (*ContractServer, error)

func (*ContractServer) Close

func (s *ContractServer) Close(ctx context.Context) error

type E2ATestServer

type E2ATestServer struct {
	HTTPServer *httptest.Server
	SMTPAddr   string
	Store      *identity.Store
	Signer     *headers.Signer
	WSHub      *ws.Hub
	// contains filtered or unexported fields
}

func TestServer

func TestServer(t *testing.T, pool *pgxpool.Pool) *E2ATestServer

type ReceivedPayload

type ReceivedPayload struct {
	Body    webhook.Payload
	Headers http.Header
	RawBody []byte
}

type SMTPAddr

type SMTPAddr struct {
	Host string
	Port int
}

SMTPAddr holds parsed host and port for a fake SMTP server.

func FakeSMTPServer

func FakeSMTPServer(t *testing.T) (SMTPAddr, func() []SMTPMessage)

FakeSMTPServer starts a minimal SMTP server that accepts messages. Returns the address and a function to call to stop the server and get received messages.

type SMTPMessage

type SMTPMessage struct {
	From       string
	To         string   // first RCPT TO (backward compat)
	Recipients []string // all RCPT TO addresses
	Data       string
}

SMTPMessage represents a message received by the fake SMTP server.

type WebhookReceiverResult

type WebhookReceiverResult struct {
	Server *httptest.Server
	// contains filtered or unexported fields
}

func WebhookReceiver

func WebhookReceiver(t *testing.T) *WebhookReceiverResult

func (*WebhookReceiverResult) Payloads

func (w *WebhookReceiverResult) Payloads() []ReceivedPayload

func (*WebhookReceiverResult) WaitForPayloads

func (w *WebhookReceiverResult) WaitForPayloads(t *testing.T, count int, timeout time.Duration) []ReceivedPayload

Jump to

Keyboard shortcuts

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