helpers

package
v0.0.1-dev.7 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AlpineImage = "alpine:latest"
)

Functions

func GetEnvOrDefault

func GetEnvOrDefault(name, defaultValue string) string

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

func IsCI

func IsCI() bool

IsCI returns true if running in a CI environment

func RequireEnvVar

func RequireEnvVar(t *testing.T, name string) string

RequireEnvVar ensures that an environment variable is set, skipping the test if not present

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) Close

func (h *DockerHelper) Close() error

Close closes the Docker client

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

func (h *DockerHelper) GetContainerLogs(ctx context.Context, containerID string) (string, error)

GetContainerLogs retrieves logs from a container

func (*DockerHelper) RemoveContainer

func (h *DockerHelper) RemoveContainer(ctx context.Context, containerID string, force bool) error

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 StoreType

type StoreType string

StoreType defines the type of store to use in tests

const (
	StoreTypeMemory StoreType = "memory"
	StoreTypeBadger StoreType = "badger"
)

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

func (h *TestHelper) CreateTestService(ctx context.Context, svc *types.Service) error

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

func (h *TestHelper) RunCommandWithTimeout(timeout time.Duration, args ...string) (string, error)

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

Jump to

Keyboard shortcuts

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