world

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const BehaviourScriptRepoPath = "behaviour/current-scenario.yaml"

Variables

This section is empty.

Functions

func WithWorld added in v0.33.0

func WithWorld(ctx context.Context, w *World) context.Context

WithWorld returns a new context that carries w.

Types

type RepoPool added in v0.33.0

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

RepoPool is an in-process lease pool for logical test-repo names. Scenarios acquire a unique name for their duration and release it afterward, ensuring no two concurrent scenarios use the same repo.

func NewRepoPool added in v0.33.0

func NewRepoPool(size int) (*RepoPool, error)

NewRepoPool creates a pool pre-filled with size names in the form "test-repo-01" … "test-repo-NN". Returns an error if size is not positive.

func (*RepoPool) Acquire added in v0.33.0

func (p *RepoPool) Acquire(ctx context.Context) (string, error)

Acquire blocks until a repo name is available or ctx is cancelled.

func (*RepoPool) Release added in v0.33.0

func (p *RepoPool) Release(name string) error

Release returns a previously acquired name to the pool. It returns an error if the name is not an outstanding lease (e.g. double-release). Callers in godog After hooks should surface the error rather than allowing a panic to crash the test runner.

func (*RepoPool) Size added in v0.33.0

func (p *RepoPool) Size() int

Size returns the total capacity of the pool.

type World

type World struct {
	Config  env.RunnerConfig
	SCM     scm.Driver
	CI      ci.Driver
	Install install.State

	Org       string
	RepoFull  string
	RepoOwner string
	RepoName  string
	Token     string
	Logf      func(string, ...any)

	// FixturesRoot is module-relative (e.g. "e2e/behaviour" or "behaviour").
	FixturesRoot string

	ScenarioStart time.Time

	DummyOps           []runtime.BehaviourOperation
	ArtifactDir        string
	TriageTriggerEvent string // GitHub event for triage dispatch (issues for label path)

	IssueNumber    int
	IssueTitle     string
	WorkflowRun    *forge.WorkflowRun
	TriageWorkflow string

	DispatchAgent string
	PRNumber      int

	// Fork context — set by fork step definitions.
	ForkOwner    string
	ForkRepo     string
	ForkPRNumber int
	ForkPRBranch string

	// URL harness hosting repo — set by URL dispatch step definitions.
	URLHarnessRepoOwner string
	URLHarnessRepoName  string

	// LeasedRepoName is the logical test-repo name acquired from a RepoPool
	// for this scenario's duration. Empty when no pool is configured.
	LeasedRepoName string

	// Ensurer lazily creates and installs repos on demand. Shared across
	// scenarios (like other driver fields) and safe for concurrent use.
	// Nil when lazy ensure is not configured.
	Ensurer install.RepoEnsurer

	// KillSwitchActivated records whether this scenario activated the
	// repo-level kill switch. CleanupScenario uses this to deactivate
	// the switch so the next scenario on this slot is not affected.
	KillSwitchActivated bool

	// Jira mock state — set by the "Given a mock Jira server" step.
	JiraMockServer *httptest.Server
	JiraMockState  *jiramock.State
	JiraConfigDir  string // temp dir holding .fullsend/ layout for the poller
}

World holds scenario state and injected drivers.

func FromContext added in v0.33.0

func FromContext(ctx context.Context) *World

FromContext extracts the per-scenario World stored by WithWorld. Returns nil if no World is present.

func (*World) BehaviourScriptPath

func (w *World) BehaviourScriptPath() string

BehaviourScriptPath returns the repo-relative path for the dummy agent script.

func (*World) Clone added in v0.33.0

func (w *World) Clone() *World

Clone creates a shallow copy of w. Drivers and shared state (SCM, CI, Install as install.State) are shared by reference — this is safe because the production implementations are immutable wrappers:

  • scm/github.Driver holds only a forge.Client (concurrent-safe).
  • ci/githubactions.Driver holds a forge.Client and an immutable Token.
  • install.perRepoState holds only immutable string fields.

Race tests in each driver package (TestConcurrentAccess, TestConcurrentStateAccess) verify the real types under -race with forge.FakeClient. See scm.Driver, ci.Driver, and install.State doc comments for the concurrency contract.

Scenario-level fields are copied verbatim; callers should call resetScenarioWorld (in package suite) to zero them for each new scenario.

Jump to

Keyboard shortcuts

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