Documentation
¶
Index ¶
- Variables
- func GetEnvOrDefault(name, defaultValue string) string
- func IntegrationTest(t *testing.T, testFunc func(ctx context.Context, h *DockerHelper))
- func IsCI() bool
- func RequireEnvVar(t *testing.T, name string) string
- type DockerHelper
- func (h *DockerHelper) CleanupContainer(ctx context.Context, containerID string)
- func (h *DockerHelper) Close() error
- func (h *DockerHelper) CreateContainer(ctx context.Context, config *container.Config, ...) (string, error)
- func (h *DockerHelper) EnsureImage(ctx context.Context, image string) error
- func (h *DockerHelper) ExecCommand(ctx context.Context, containerID string, cmd []string) (string, error)
- func (h *DockerHelper) GetContainerLogs(ctx context.Context, containerID string) (string, error)
- func (h *DockerHelper) RemoveContainer(ctx context.Context, containerID string, force bool) error
- func (h *DockerHelper) StartContainer(ctx context.Context, containerID string) error
- func (h *DockerHelper) StopContainer(ctx context.Context, containerID string, timeout time.Duration) error
- type StoreType
- type TestHelper
- func (h *TestHelper) Cleanup()
- func (h *TestHelper) CreateTestService(ctx context.Context, svc *types.Service) error
- func (h *TestHelper) GetService(ctx context.Context, namespace, name string) (*types.Service, error)
- func (h *TestHelper) RunCommand(args ...string) (string, error)
- func (h *TestHelper) RunCommandWithTimeout(timeout time.Duration, args ...string) (string, error)
- func (h *TestHelper) StartAPIServer() *server.APIServer
- func (h *TestHelper) TempDir() string
Constants ¶
This section is empty.
Variables ¶
var (
AlpineImage = "alpine:latest"
)
Functions ¶
func GetEnvOrDefault ¶
GetEnvOrDefault gets an environment variable or returns the default value if not set
func IntegrationTest ¶
func IntegrationTest(t *testing.T, testFunc func(ctx context.Context, h *DockerHelper))
IntegrationTest provides a structured way to set up and tear down integration tests
Types ¶
type DockerHelper ¶
type DockerHelper struct {
// contains filtered or unexported fields
}
DockerHelper provides utilities for working with Docker containers in tests
func NewDockerHelper ¶
func NewDockerHelper() (*DockerHelper, error)
NewDockerHelper creates a new Docker helper instance
func (*DockerHelper) CleanupContainer ¶
func (h *DockerHelper) CleanupContainer(ctx context.Context, containerID string)
CleanupContainer stops and removes a container
func (*DockerHelper) CreateContainer ¶
func (h *DockerHelper) CreateContainer(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, name string) (string, error)
CreateContainer creates a new container
func (*DockerHelper) EnsureImage ¶
func (h *DockerHelper) EnsureImage(ctx context.Context, image string) error
EnsureImage ensures the specified image is available, pulling it if necessary
func (*DockerHelper) ExecCommand ¶
func (h *DockerHelper) ExecCommand(ctx context.Context, containerID string, cmd []string) (string, error)
ExecCommand executes a command in a running container
func (*DockerHelper) GetContainerLogs ¶
GetContainerLogs retrieves logs from a container
func (*DockerHelper) RemoveContainer ¶
RemoveContainer removes a container
func (*DockerHelper) StartContainer ¶
func (h *DockerHelper) StartContainer(ctx context.Context, containerID string) error
StartContainer starts a container
func (*DockerHelper) StopContainer ¶
func (h *DockerHelper) StopContainer(ctx context.Context, containerID string, timeout time.Duration) error
StopContainer stops a container
type TestHelper ¶
type TestHelper struct {
// contains filtered or unexported fields
}
TestHelper provides utilities for integration testing Default mode uses the mock CLI (rune-test) for fast, deterministic tests. The helper-configured store (memory or badger) is used for verification and for any in-process server startup.
func NewTestHelper ¶
func NewTestHelper(t *testing.T) *TestHelper
NewTestHelper creates a new test helper with configurable store type
func NewTestHelperWithStore ¶
func NewTestHelperWithStore(t *testing.T, storeType StoreType) *TestHelper
NewTestHelperWithStore creates a new test helper with specified store type
func (*TestHelper) Cleanup ¶
func (h *TestHelper) Cleanup()
Cleanup removes temporary test resources
func (*TestHelper) CreateTestService ¶
CreateTestService creates a service directly in the store for testing
func (*TestHelper) GetService ¶
func (h *TestHelper) GetService(ctx context.Context, namespace, name string) (*types.Service, error)
GetService directly accesses the memory store to verify a service was created
func (*TestHelper) RunCommand ¶
func (h *TestHelper) RunCommand(args ...string) (string, error)
RunCommand executes a rune CLI command
func (*TestHelper) RunCommandWithTimeout ¶
RunCommandWithTimeout executes a rune CLI command with a timeout
func (*TestHelper) StartAPIServer ¶
func (h *TestHelper) StartAPIServer() *server.APIServer
StartAPIServer starts a test API server using the helper-configured store. Note: The mock CLI path (rune-test) does not use this server; it is provided for tests that want an in-process server for subsystem validation.
func (*TestHelper) TempDir ¶
func (h *TestHelper) TempDir() string
TempDir returns the temporary directory for this test