Documentation
¶
Index ¶
- func ApplySchema(t *testing.T, log *TestLogger, db *sql.DB, schemaDirectory string)
- func FindRepoRoot(t *testing.T) string
- func SchemaDir(relativePath string) string
- type ComposeStack
- func (s *ComposeStack) ConnectGRPC(serviceName string, containerPort int) (*grpc.ClientConn, error)
- func (s *ComposeStack) ConnectMySQLService(serviceName string) (*sql.DB, error)
- func (s *ComposeStack) MySQLServiceDSN(serviceName string) (string, error)
- func (s *ComposeStack) ServiceExitCode(serviceName string) (int, error)
- func (s *ComposeStack) ServiceHost(serviceName string, containerPort int) (string, error)
- func (s *ComposeStack) ServicePort(serviceName string, containerPort int) (int, error)
- func (s *ComposeStack) StopService(serviceName string, timeoutSec int) error
- func (s *ComposeStack) Up() error
- type TestLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplySchema ¶
ApplySchema reads all .sql files from the schema directory and executes them on the database.
func FindRepoRoot ¶
FindRepoRoot finds the repository root. Checks REPO_ROOT env var, then git, then walks up to find marker files.
Types ¶
type ComposeStack ¶
type ComposeStack struct {
// contains filtered or unexported fields
}
ComposeStack manages a docker-compose stack for testing.
func NewComposeStack ¶
func NewComposeStack(t *testing.T, log *TestLogger, ctx context.Context, composeFile, testContext string) *ComposeStack
NewComposeStack creates a new compose stack from the given docker-compose file. Automatically registers cleanup to tear down the stack. testContext should describe what's being tested (e.g., "gateway", "storage", "e2e-submitqueue").
func (*ComposeStack) ConnectGRPC ¶
func (s *ComposeStack) ConnectGRPC(serviceName string, containerPort int) (*grpc.ClientConn, error)
ConnectGRPC creates a gRPC client connection to a service.
func (*ComposeStack) ConnectMySQLService ¶
func (s *ComposeStack) ConnectMySQLService(serviceName string) (*sql.DB, error)
ConnectMySQLService connects to a MySQL service by name in the compose stack. Requires that Up() has been called first — the TCP-based healthcheck in docker-compose ensures MySQL is accepting TCP connections before Up() returns.
func (*ComposeStack) MySQLServiceDSN ¶
func (s *ComposeStack) MySQLServiceDSN(serviceName string) (string, error)
MySQLServiceDSN returns the DSN string for a MySQL service. Useful when the implementation manages its own database connection.
func (*ComposeStack) ServiceExitCode ¶
func (s *ComposeStack) ServiceExitCode(serviceName string) (int, error)
ServiceExitCode returns the exit code of a stopped service container. Must be called after the service has exited.
func (*ComposeStack) ServiceHost ¶
func (s *ComposeStack) ServiceHost(serviceName string, containerPort int) (string, error)
ServiceHost returns the host:port address for a service.
func (*ComposeStack) ServicePort ¶
func (s *ComposeStack) ServicePort(serviceName string, containerPort int) (int, error)
ServicePort returns the mapped host port for a service's container port.
func (*ComposeStack) StopService ¶
func (s *ComposeStack) StopService(serviceName string, timeoutSec int) error
StopService sends SIGTERM to a service and waits for it to stop. timeoutSec is the maximum time to wait before Docker sends SIGKILL.
func (*ComposeStack) Up ¶
func (s *ComposeStack) Up() error
Up starts all services in the compose stack. Uses --wait to block until all services with healthcheck directives are healthy.
type TestLogger ¶
type TestLogger struct {
// contains filtered or unexported fields
}
TestLogger is a simple test-aware logger that records elapsed time between logs.
func NewTestLogger ¶
func NewTestLogger(t *testing.T) *TestLogger
NewTestLogger creates a TestLogger for the current test.
func (*TestLogger) Logf ¶
func (l *TestLogger) Logf(format string, args ...any)
Logf prints a formatted log message with timestamp and elapsed time since last log.