scenarios

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package scenarios provides a shared scenario catalog consumable by both Go tests and the Ruby integration harness.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog

type Catalog struct {
	Version    int        `yaml:"version"`
	Categories []Category `yaml:"categories"`
	Scenarios  []Scenario `yaml:"scenarios"`
}

Catalog is the top-level structure of catalog.yml.

func Load

func Load() (*Catalog, error)

Load reads the catalog from the canonical location relative to this package's source file. Suitable for use in tests.

func LoadFrom

func LoadFrom(path string) (*Catalog, error)

LoadFrom reads and parses a catalog from the given path.

func (*Catalog) ByCategory

func (c *Catalog) ByCategory(cat string) []Scenario

ByCategory returns scenarios matching the given category name.

func (*Catalog) ByTag

func (c *Catalog) ByTag(tag string) []Scenario

ByTag returns scenarios having the given tag.

func (*Catalog) Names

func (c *Catalog) Names() []string

Names returns all scenario names.

type Category

type Category struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
}

Category groups related scenarios.

type Expect

type Expect struct {
	Exit           *int     `yaml:"exit"`
	ExitAny        []int    `yaml:"exit_any"`
	OutputContains []string `yaml:"output_contains"`
	OutputExcludes []string `yaml:"output_excludes"`
	StdoutContains []string `yaml:"stdout_contains"`
	StdoutIsJSON   bool     `yaml:"stdout_is_json"`
	LockfileExists bool     `yaml:"lockfile_exists"`
	// LockfileExcludes asserts the generated lockfile does NOT contain each
	// substring — e.g. `$/` self refs, which are inherently pinned and must
	// never be recorded.
	LockfileExcludes []string `yaml:"lockfile_excludes,omitempty"`
	// FilesContain / FilesExclude assert substrings in repo-relative files
	// after the run, used to verify `./`→`$/` rewrites in workflows and
	// in-repo composite action.yml files.
	FilesContain map[string][]string    `yaml:"files_contain,omitempty"`
	FilesExclude map[string][]string    `yaml:"files_exclude,omitempty"`
	Custom       string                 `yaml:"custom"`
	JQ           []JQCheck              `yaml:"jq,omitempty"`
	GoldenJSON   map[string]interface{} `yaml:"golden_json,omitempty"`
}

Expect declares assertions on the scenario outcome.

type Fixtures

type Fixtures struct {
	Workflows        map[string]WorkflowFixture `yaml:"workflows"`
	Lockfile         string                     `yaml:"lockfile"`
	LockfileTemplate string                     `yaml:"lockfile_template"`
	// Files lays down arbitrary repo-relative files before the run, e.g.
	// in-repo composite action.yml definitions that the default-on migration
	// should also rewrite. Paths are relative to the repo root, not the
	// workflows dir.
	Files map[string]string `yaml:"files"`
}

Fixtures describes the file-system setup for a scenario.

type JQCheck

type JQCheck struct {
	Expr        string `yaml:"expr"`
	Equals      string `yaml:"equals,omitempty"`
	Contains    string `yaml:"contains,omitempty"`
	NotEquals   string `yaml:"not_equals,omitempty"`
	Matches     string `yaml:"matches,omitempty"`
	GreaterThan *int   `yaml:"greater_than,omitempty"`
}

JQCheck is a single jq-based assertion on JSON output.

type Scenario

type Scenario struct {
	Name        string   `yaml:"name"`
	Category    string   `yaml:"category"`
	Description string   `yaml:"description"`
	NeedsToken  bool     `yaml:"needs_token"`
	NeedsStub   bool     `yaml:"needs_stub"`
	Skip        string   `yaml:"skip,omitempty"`
	Tags        []string `yaml:"tags"`
	Flags       []string `yaml:"flags"`
	LiveRepo    string   `yaml:"live_repo"`

	// Env sets or unsets process environment variables for the run. A nil
	// value unsets the variable (YAML null), letting scenarios strip ambient
	// auth or redirect GH_HOST to prove offline behavior.
	Env map[string]*string `yaml:"env,omitempty"`

	Fixtures Fixtures `yaml:"fixtures"`
	Expect   Expect   `yaml:"expect"`
}

Scenario describes a single test scenario.

func (*Scenario) HasTag

func (s *Scenario) HasTag(tag string) bool

HasTag reports whether the scenario has the given tag.

type WorkflowFixture

type WorkflowFixture struct {
	Name    string   `yaml:"name"`
	Actions []string `yaml:"actions"`
	Raw     string   `yaml:"raw"`
}

WorkflowFixture is either a structured action list or raw YAML.

Jump to

Keyboard shortcuts

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