fixtures

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package fixtures is the single source of truth for the e2e fixture set shared between the docker-backend harness (internal/e2e) and the cluster- backend harness (internal/clustere2e). Both harnesses iterate All() so any fixture added here automatically runs on both backends, with divergences captured per-fixture rather than by silently omitting tests on one side.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBareRepoFromSeed added in v1.6.0

func BuildBareRepoFromSeed(seedDir, tmpDir string) (string, error)

BuildBareRepoFromSeed walks `seedDir`, copies its full tree into a fresh working repo under `tmpDir/work`, initialises a bare repo at `tmpDir/repo.git`, commits, and pushes. Returns the file:// URL of the bare repo so the e2e fixture's pipeline.yaml can resolve against it. Used by the docker and cluster e2e harnesses to materialise the `resolver-git` fixture's source-of-truth without committing a binary .git tree into the repo. Mirrors the helper used by the unit-test `internal/refresolver/git_test.go` so the harness shape and the unit-test shape stay aligned.

`tmpDir` should typically be `t.TempDir()` from a Go test.

func ResultsEqual added in v1.5.0

func ResultsEqual(got, want map[string]any) bool

ResultsEqual compares two RunResult.Results-style maps for cross- backend fidelity, treating []string and []any-of-strings as equal and map[string]string vs map[string]any-of-strings as equal. The docker engine builds typed []string / map[string]string; fixture authors usually write []any literals. Either side may also be nil or empty when the other is — both mean "no resolved results."

Types

type Fixture

type Fixture struct {
	// Dir under testdata/e2e (e.g. "hello", "volumes").
	Dir string
	// Pipeline is the pipeline name to run (a YAML may declare several).
	Pipeline string
	// Params for the pipeline run (key=value).
	Params map[string]string
	// WantStatus is the expected engine.RunResult.Status.
	WantStatus string
	// ConfigMaps maps name -> key -> inline value, seeded into the
	// configMap volumes.Store before the run.
	ConfigMaps map[string]map[string]string
	// Secrets is the same shape, seeded into the secret store.
	Secrets map[string]map[string]string
	// DockerOnly: skip in the cluster harness.
	DockerOnly bool
	// ClusterOnly: skip in the docker harness.
	ClusterOnly bool
	// Name is the Go subtest name used by t.Run; defaults to a derived form
	// when empty (see TestName).
	Name string
	// Description is a one-liner used in failure messages.
	Description string
	// WantResults, when non-nil, asserts engine.RunResult.Results is
	// equal (after a normalising pass — []string and []any with string
	// items count as equal, etc.) to this map. The cross-backend
	// fidelity guarantee for Pipeline.spec.results: both backends must
	// produce the same Results map for any fixture that sets this. If
	// nil, only WantStatus is asserted (the existing behavior).
	WantResults map[string]any
	// WantEventFields, if non-nil, asserts that for each named event
	// kind the first matching event in the captured stream carries
	// each named JSON-key/value pair. Shape:
	//   kind -> { jsonKey -> expectedValue }
	// Only the first event of each kind is inspected (run-start /
	// run-end always have exactly one; task-start / step-log are
	// asserted on the first emission). Skipped if the map is nil.
	WantEventFields map[string]map[string]string
	// Resolver, when non-empty, signals the e2e harness to:
	//   1. Spin up an httptest.Server before the run, serving files from
	//      testdata/e2e/<Dir>/served/.
	//   2. Configure engine.Options.Refresolver with a default registry
	//      whose `hub` resolver's BaseURL is rewritten to the test
	//      server (Resolver=="hub") or whose `http` resolver targets it
	//      via the fixture-server-url Pipeline param (Resolver=="http").
	//   3. Inject a fixture-server-url Pipeline param so the Pipeline's
	//      $(params.fixture-server-url) resolves at run time.
	// Phase 3 of Track 1 #9 wires these for cross-backend e2e coverage
	// of the hub + http direct resolvers; the cluster harness produces
	// the same inlined TaskSpec since resolution is client-side.
	// Empty value: not a resolver fixture (the existing behavior).
	Resolver string
}

Fixture describes one testdata/e2e/<dir> case in a backend-agnostic way.

WantStatus matches engine.RunResult.Status: succeeded | failed | timeout. Inline ConfigMaps / Secrets are seeded into both backends' volume stores (docker via volumes.Store.Add; cluster via the same Store, then projected into ephemeral kube ConfigMap/Secret resources at PipelineRun submit time).

DockerOnly / ClusterOnly are the explicit divergence escape hatches: a fixture flagged DockerOnly is skipped by the cluster harness (and vice versa), and the reason should be stated in Description. After Track 2 completes, every entry below is expected to leave both flags false.

func All

func All() []Fixture

All returns every shared e2e fixture. Order is stable across calls so failure logs line up between runs.

Backend-divergent fixtures carry DockerOnly / ClusterOnly with a Description explaining why; the goal is to flip every flag to false as each backend gains the missing capability. As of the cross-backend- fidelity work, every entry below runs on both backends.

func (Fixture) TestName

func (f Fixture) TestName() string

TestName returns the subtest name for this fixture: explicit Name when set, otherwise the directory + pipeline + sorted-params suffix so two fixtures over the same dir with different params get distinct names.

type ResolverHarness added in v1.6.0

type ResolverHarness struct {
	Server   *httptest.Server
	Registry *refresolver.Registry
	// ExtraParam is a single (name, value) tuple the caller MUST add to
	// the Pipeline's run params before invoking RunPipeline. For "http"
	// fixtures it carries the test server's base URL via
	// fixture-server-url; for "hub" fixtures the resolver targets the
	// server through Registry construction so this field is empty.
	// For "bundles" fixtures it carries the OCI ref the test
	// registry serves at, so the Pipeline's $(params.bundle-ref)
	// resolves to a working reference.
	ExtraParamName  string
	ExtraParamValue string
}

ResolverHarness wires up an httptest.Server + a refresolver.Registry for a fixture flagged Resolver=="http"|"hub"|"bundles". Both e2e harnesses (docker + cluster) use this so the resolver dispatch path is exercised identically across backends. The returned struct's Cleanup must be called after the run.

func NewResolverHarness added in v1.6.0

func NewResolverHarness(fixtureDir, resolverName string) (*ResolverHarness, error)

NewResolverHarness sets up the test server + registry for the given fixture's Resolver string. fixtureDir is the absolute path to testdata/e2e/<dir>; the served/ subdirectory is the corpus the test server returns. Empty Resolver returns nil (harness inactive).

func (*ResolverHarness) Close added in v1.6.0

func (h *ResolverHarness) Close()

Close shuts down the test server.

Jump to

Keyboard shortcuts

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