Documentation
¶
Overview ¶
Package testing provides test integration for preview environments. It triggers CI pipeline runs and polls for their completion status.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Providers = registry.New[TestRunner]("test-runner")
Providers is the registry of available TestRunner implementations.
Functions ¶
This section is empty.
Types ¶
type GitHubActionsRunner ¶
type GitHubActionsRunner struct {
BaseURL string // defaults to https://api.github.com
Token string
HTTPClient *http.Client
}
GitHubActionsRunner triggers and polls GitHub Actions workflow runs.
func (*GitHubActionsRunner) Status ¶
func (r *GitHubActionsRunner) Status(ctx context.Context, env *v1alpha1.Environment, runID string) (*TestResult, error)
Status checks the current state of a GitHub Actions workflow run.
func (*GitHubActionsRunner) Trigger ¶
func (r *GitHubActionsRunner) Trigger(ctx context.Context, env *v1alpha1.Environment) (string, error)
Trigger starts a GitHub Actions workflow dispatch event.
type GitLabPipelineRunner ¶
GitLabPipelineRunner triggers and polls GitLab CI pipelines.
func (*GitLabPipelineRunner) Status ¶
func (r *GitLabPipelineRunner) Status(ctx context.Context, env *v1alpha1.Environment, runID string) (*TestResult, error)
func (*GitLabPipelineRunner) Trigger ¶
func (r *GitLabPipelineRunner) Trigger(ctx context.Context, env *v1alpha1.Environment) (string, error)
type NoopTestRunner ¶
type NoopTestRunner struct{}
NoopTestRunner is a no-op implementation used when testing is not configured.
func (*NoopTestRunner) Status ¶
func (n *NoopTestRunner) Status(_ context.Context, _ *v1alpha1.Environment, _ string) (*TestResult, error)
func (*NoopTestRunner) Trigger ¶
func (n *NoopTestRunner) Trigger(_ context.Context, _ *v1alpha1.Environment) (string, error)
type TestResult ¶
type TestResult struct {
State v1alpha1.TestState
Summary string
URL string
// ResolvedRunID is the actual ID of the run if it was resolved from a pending state.
ResolvedRunID string
}
TestResult holds the result of a test run poll.
type TestRunner ¶
type TestRunner interface {
// Trigger starts a test run against the preview environment.
// Returns an opaque RunID that can be used for subsequent Status polls.
Trigger(ctx context.Context, env *v1alpha1.Environment) (runID string, err error)
// Status polls for the current state of a previously triggered test run.
// Returns a TestResult with State=TestStateRunning while the run is in progress.
Status(ctx context.Context, env *v1alpha1.Environment, runID string) (*TestResult, error)
}
TestRunner triggers test runs and polls for their completion.
Click to show internal directories.
Click to hide internal directories.