Documentation
¶
Index ¶
- type ContainerConfig
- type TestContainer
- func (c *TestContainer) APIBaseURL() string
- func (c *TestContainer) APIClient() (*instanceoapi.ClientWithResponses, error)
- func (c *TestContainer) APIClientNoKeepAlive() (*instanceoapi.ClientWithResponses, error)
- func (c *TestContainer) CDPAddr() string
- func (c *TestContainer) CDPURL() string
- func (c *TestContainer) Container() testcontainers.Container
- func (c *TestContainer) Exec(ctx context.Context, cmd []string) (int, string, error)
- func (c *TestContainer) ExitCh() <-chan error
- func (c *TestContainer) Start(ctx context.Context, cfg ContainerConfig) error
- func (c *TestContainer) Stop(ctx context.Context) error
- func (c *TestContainer) WaitDevTools(ctx context.Context) error
- func (c *TestContainer) WaitReady(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContainerConfig ¶
type ContainerConfig struct {
Env map[string]string
HostAccess bool // Add host.docker.internal mapping
}
ContainerConfig holds optional configuration for container startup.
type TestContainer ¶
type TestContainer struct {
Name string
Image string
APIPort int // dynamically allocated host port -> container 10001
CDPPort int // dynamically allocated host port -> container 9222
// contains filtered or unexported fields
}
TestContainer wraps testcontainers-go to manage a Docker container for e2e tests. This enables parallel test execution by giving each test its own dynamically allocated ports.
func NewTestContainer ¶
func NewTestContainer(tb testing.TB, image string) *TestContainer
NewTestContainer creates a new test container placeholder. The actual container is started when Start() is called. Works with both *testing.T and *testing.B (any testing.TB).
func (*TestContainer) APIBaseURL ¶
func (c *TestContainer) APIBaseURL() string
APIBaseURL returns the URL for the container's API server.
func (*TestContainer) APIClient ¶
func (c *TestContainer) APIClient() (*instanceoapi.ClientWithResponses, error)
APIClient creates an OpenAPI client for this container's API.
func (*TestContainer) APIClientNoKeepAlive ¶
func (c *TestContainer) APIClientNoKeepAlive() (*instanceoapi.ClientWithResponses, error)
APIClientNoKeepAlive creates an API client that doesn't reuse connections. This is useful after server restarts where existing connections may be stale.
func (*TestContainer) CDPAddr ¶
func (c *TestContainer) CDPAddr() string
CDPAddr returns the TCP address for the container's DevTools proxy.
func (*TestContainer) CDPURL ¶
func (c *TestContainer) CDPURL() string
CDPURL returns the WebSocket URL for the container's DevTools proxy.
func (*TestContainer) Container ¶
func (c *TestContainer) Container() testcontainers.Container
Container returns the underlying testcontainers.Container for advanced usage.
func (*TestContainer) Exec ¶
Exec executes a command inside the container and returns the combined output.
func (*TestContainer) ExitCh ¶
func (c *TestContainer) ExitCh() <-chan error
ExitCh returns a channel that receives when the container exits. Note: testcontainers-go handles this internally; this is kept for API compatibility.
func (*TestContainer) Start ¶
func (c *TestContainer) Start(ctx context.Context, cfg ContainerConfig) error
Start starts the container with the given configuration using testcontainers-go.
func (*TestContainer) Stop ¶
func (c *TestContainer) Stop(ctx context.Context) error
Stop stops and removes the container.
func (*TestContainer) WaitDevTools ¶
func (c *TestContainer) WaitDevTools(ctx context.Context) error
WaitDevTools waits for the CDP WebSocket endpoint to be ready.
func (*TestContainer) WaitReady ¶
func (c *TestContainer) WaitReady(ctx context.Context) error
WaitReady waits for the container's API to become ready. Note: With testcontainers-go, this is usually handled by the wait strategy in Start(). This method is kept for compatibility and performs an additional health check.