devtest

package
v0.0.0-...-3776344 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultHealthPath is the built-in health endpoint exposed by the Celerity
	// runtime. It is always registered unless the developer sets
	// CELERITY_USE_CUSTOM_HEALTH_CHECK=true in the runtime environment.
	DefaultHealthPath = "/runtime/health/check"
)

Variables

ValidSuites are the accepted values for the --suite flag. Multiple suites can be comma-separated: --suite unit,integration

Functions

func WaitForHealth

func WaitForHealth(
	ctx context.Context,
	baseURL string,
	healthPath string,
	timeout time.Duration,
	output *devrun.Output,
) error

WaitForHealth polls the given base URL + health path until the server responds with a 2xx status code or the timeout expires.

healthPath overrides the endpoint to poll. When empty, DefaultHealthPath is used. Developers who set CELERITY_USE_CUSTOM_HEALTH_CHECK=true can pass their custom path via --health-path.

Types

type InfraLevel

type InfraLevel int

InfraLevel describes the infrastructure needed for a set of test suites.

const (
	// InfraLevelNone means no Docker infrastructure is needed (unit tests only).
	InfraLevelNone InfraLevel = iota

	// InfraLevelCompose starts compose dependencies (databases, caches, etc.)
	// but not the app container. Used for integration tests.
	InfraLevelCompose

	// InfraLevelFull starts compose dependencies AND the app container.
	// Used for API tests.
	InfraLevelFull
)

func InfraLevelForSuites

func InfraLevelForSuites(suites []TestSuite) InfraLevel

InfraLevelForSuites determines the highest infrastructure level needed for the given set of test suites.

type NodeRunner

type NodeRunner struct {
	// contains filtered or unexported fields
}

NodeRunner executes tests for Node.js projects.

func NewNodeRunner

func NewNodeRunner(logger *zap.Logger) *NodeRunner

NewNodeRunner creates a new Node.js test runner.

func (*NodeRunner) Run

func (r *NodeRunner) Run(ctx context.Context, config RunConfig) (*RunResult, error)

Run executes the configured test suites for a Node.js project.

type PythonRunner

type PythonRunner struct {
	// contains filtered or unexported fields
}

PythonRunner executes tests for Python projects.

func NewPythonRunner

func NewPythonRunner(logger *zap.Logger) *PythonRunner

NewPythonRunner creates a new Python test runner.

func (*PythonRunner) Run

func (r *PythonRunner) Run(ctx context.Context, config RunConfig) (*RunResult, error)

Run executes the configured test suites for a Python project.

type RunConfig

type RunConfig struct {
	// AppDir is the absolute path to the application root directory.
	AppDir string

	// Runtime is the detected runtime string (e.g. "nodejs22.x", "python3.12.x").
	Runtime string

	// Suites lists which test suites to execute.
	Suites []TestSuite

	// Coverage enables coverage reporting when true.
	Coverage bool

	// TestCommand is a user-provided override for the test command.
	// When non-empty, auto-detection is skipped and this command is
	// executed directly via the shell.
	TestCommand string

	// HostPort is the host port the app container is listening on.
	// Used to construct CELERITY_TEST_BASE_URL for API tests.
	HostPort string

	// Verbose enables debug-level output from the test runner.
	Verbose bool

	// Env holds additional environment variables to pass to the test process.
	// Typically contains infrastructure endpoints (databases, caches, etc.)
	// rewritten for host access.
	Env map[string]string
}

RunConfig holds configuration for a test run.

type RunResult

type RunResult struct {
	// ExitCode is the exit code from the test runner process.
	// 0 means all tests passed.
	ExitCode int

	// CoveragePath is the path to the coverage report, if generated.
	CoveragePath string
}

RunResult holds the outcome of a test run.

type RunnerFactory

type RunnerFactory func(logger *zap.Logger) TestRunner

RunnerFactory creates a TestRunner for a given runtime.

type TestRunner

type TestRunner interface {
	// Run executes the configured test suites and returns the result.
	// The runner streams output to stdout/stderr in real time.
	Run(ctx context.Context, config RunConfig) (*RunResult, error)
}

TestRunner executes tests for a specific runtime.

func RunnerForRuntime

func RunnerForRuntime(runtime string, logger *zap.Logger) (TestRunner, error)

RunnerForRuntime returns a TestRunner for the given runtime string, matching by prefix (e.g. "nodejs24.x" matches "nodejs").

type TestSuite

type TestSuite string

TestSuite identifies which test suites to run.

const (
	SuiteUnit        TestSuite = "unit"
	SuiteIntegration TestSuite = "integration"
	SuiteAPI         TestSuite = "api"
)

Directories

Path Synopsis
Package detect provides pure detection and command-building logic for test runners, extracted so it can be unit-tested without executing shell commands.
Package detect provides pure detection and command-building logic for test runners, extracted so it can be unit-tested without executing shell commands.

Jump to

Keyboard shortcuts

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