Documentation
¶
Overview ¶
Package scenario is the format of e2e/scenarios/<slug>/: scenario.yaml (the command line, the environment, the mocks' response sequences) and expected.json (the exit code and the JSON document, "*" for a value the scenario does not pin). e2e/README.md documents it for the people who add scenarios; this package is where the harness reads it.
Index ¶
Constants ¶
const ( ScenarioFile = "scenario.yaml" ExpectedFile = "expected.json" )
File names of a scenario directory.
const DefaultTimeout = 60 * time.Second
DefaultTimeout bounds one scenario's run of the binary.
const Wildcard = "*"
Wildcard is the expected value that matches anything.
Variables ¶
This section is empty.
Functions ¶
func Discover ¶
Discover lists the directories under root that hold a scenario.yaml, sorted by name.
func Load ¶
Load reads a scenario directory. Unknown fields in either file are errors, so a misspelt key fails the scenario instead of being ignored.
func Match ¶
Match compares an actual JSON document with the expected one, both as decoded by encoding/json: objects need the same keys with matching values, arrays the same length with matching elements, scalars equality, and the Wildcard matches any value. The error names the first difference by path.
Types ¶
type Expected ¶
type Expected struct {
// ExitCode the binary must exit with.
ExitCode int `json:"exitCode"`
// JSON is the document stdout must carry, "*" standing for any value;
// left out, stdout is not compared.
JSON json.RawMessage `json:"json"`
}
Expected is expected.json.
func (Expected) ComparesJSON ¶
ComparesJSON says whether stdout is compared.
type RegistryMock ¶
type RegistryMock struct {
Mock `yaml:",inline"`
// StaleLogin makes the registry refuse every request with 401.
StaleLogin bool `yaml:"staleLogin"`
}
RegistryMock is a registry's script and state.
type Scenario ¶
type Scenario struct {
// Description says what the scenario proves, one line.
Description string `yaml:"description"`
// Args is devctl's command line without the binary.
Args []string `yaml:"args"`
// Env is added to the environment the harness builds; a variable named
// here replaces the harness's value.
Env map[string]string `yaml:"env"`
// Timeout for the run; DefaultTimeout when left out.
Timeout time.Duration `yaml:"timeout"`
// Keyring is written as JSON to the file DEVCTL_KEYRING_FILE names; left
// out, the file does not exist.
Keyring any `yaml:"keyring"`
// GitHub, CircleCI, Registry and PrivateRegistry script the mocks.
GitHub Mock `yaml:"github"`
CircleCI Mock `yaml:"circleci"`
Registry RegistryMock `yaml:"registry"`
PrivateRegistry RegistryMock `yaml:"privateRegistry"`
}
Scenario is scenario.yaml.