devtest

package
v0.0.0-...-bf62912 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 OSHandlerRunner

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

OSHandlerRunner executes tests for an application on an OS-only runtime.

Which command that is belongs to the toolchain rather than to this package. One OS-only runtime serves Go, Rust, Zig and C++, whose test layouts and runners have nothing in common, so there is no per-runtime convention to detect the way there is for Node.js and Python.

func NewOSHandlerRunner

func NewOSHandlerRunner(toolchain handlertoolchain.Toolchain, logger *zap.Logger) *OSHandlerRunner

NewOSHandlerRunner creates a runner that defers to the given toolchain.

func (*OSHandlerRunner) Run

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

Run executes the configured test suites.

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(toolchain handlertoolchain.Toolchain, logger *zap.Logger) TestRunner

RunnerFactory creates a TestRunner for a given runtime.

The toolchain is nil for a runtime that hosts the language itself, where the test command is a convention of that language rather than something the project declares.

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,
	toolchain handlertoolchain.Toolchain,
	logger *zap.Logger,
) (TestRunner, error)

RunnerForRuntime returns a TestRunner for the given runtime string, matching by longest 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