Documentation
¶
Overview ¶
Package expect provides E2E expectation execution and result types.
Index ¶
- func AttemptsCell(c CaseResult) string
- func Call(name, url string) spec.ExternalCheck
- func SuitePost(ctx context.Context, name string, block *spec.SideEffects, o SuitePostOptions) []string
- func ValidateExternal(expects spec.Expectations) []error
- func ValidateExternalCalls(loc string, calls []spec.ExternalCheck) []error
- type CaseResult
- type ImportResult
- type ImportResults
- type Options
- type Result
- func (r *Result) AllPassed() bool
- func (r *Result) CallerName() string
- func (r *Result) Duration() string
- func (r *Result) DurationWithImports() string
- func (r *Result) ExtraAttempts() int
- func (r *Result) Failed() int
- func (r *Result) Passed() int
- func (r *Result) Retried() int
- func (r *Result) Skipped() int
- func (r *Result) Summary() string
- func (r *Result) Total() int
- func (r *Result) WithImports() bool
- func (r *Result) WithImportsDuration() time.Duration
- type Runner
- type SetupFailure
- type StepResult
- type SuitePostOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttemptsCell ¶
func AttemptsCell(c CaseResult) string
AttemptsCell is a case's attempts for a report table, such as "2 of 3": blank when no retry was configured or the case was skipped.
func Call ¶
func Call(name, url string) spec.ExternalCheck
func SuitePost ¶
func SuitePost(ctx context.Context, name string, block *spec.SideEffects, o SuitePostOptions) []string
SuitePost runs a spec-level post block (the spec's onFailure or finally), named by its key, once for the suite, resolved the way an expectation is: the spec's env expanded into it once and in its commands' environment, its functions in its templates. It returns the block's warnings; a name nothing declares is one, and the block does not run.
func ValidateExternal ¶
func ValidateExternal(expects spec.Expectations) []error
ValidateExternal checks every external: call across all expect entries — each step's, and each one's onFailure and finally — with the validator a Blueprint's calls go through. Run it after ExpandIncludes, so included calls are checked too.
func ValidateExternalCalls ¶
func ValidateExternalCalls(loc string, calls []spec.ExternalCheck) []error
ValidateExternalCalls checks one external: list; loc prefixes each error. Names are required and unique within the list.
Types ¶
type CaseResult ¶
type CaseResult struct {
Name string
Passed bool
Skipped bool
Elapsed time.Duration
Err error
Attempts int `json:"attempts,omitempty"` // attempts run; 0 when skipped
Retries int `json:"retries,omitempty"` // retries configured; omitted when none
// Warnings are the case's post-block failures: an onFailure or finally
// operation that failed or whose assertions did not hold. They never
// change Passed.
Warnings []string `json:"warnings,omitempty"`
}
CaseResult holds the outcome of a single expectation.
type ImportResult ¶
type ImportResult struct {
// Path is the import path as declared in imports:
// (e.g. "./01-basic/e2e.yaml").
Path string
// Result is the structured outcome. Nil when the import failed to load or
// the runner itself errored before producing any expectations.
Result *Result
// Err is non-nil when the import failed (load error, Inrun not ready,
// or one or more expectations failed).
Err error
}
ImportResult holds the outcome of one imported E2E file in a suite run.
func (ImportResult) Name ¶
func (i ImportResult) Name() string
Name returns the display name — the E2E metadata.name when available, otherwise the import path.
func (ImportResult) Passed ¶
func (i ImportResult) Passed() bool
Passed reports whether this import succeeded.
type ImportResults ¶
type ImportResults []ImportResult
func (ImportResults) Duration ¶
func (r ImportResults) Duration() time.Duration
Duration returns the total elapsed time across all imported suites, including nested imports.
func (ImportResults) Failed ¶
func (r ImportResults) Failed() int
Failed returns the number of failed expectations across all imported suites.
func (ImportResults) Passed ¶
func (r ImportResults) Passed() int
Passed returns the number of passing expectations across all imported suites.
func (ImportResults) PrintImportSummary ¶
func (r ImportResults) PrintImportSummary(suiteName string) error
PrintImportSummary prints the suite results table and returns a non-nil error when any import failed.
func (ImportResults) Skipped ¶
func (r ImportResults) Skipped() int
Skipped returns the number of skipped expectations across all imported suites.
func (ImportResults) Total ¶
func (r ImportResults) Total() int
Total returns the total number of expectations across all imported suites.
type Options ¶
type Options struct {
WorkDir string
MaxFailures int
CS kubernetes.Interface
Cfg *rest.Config
Dynamic dynamic.Interface
Mapper apimeta.RESTMapper
// Env is the spec's env; each expectation's own env overlays it.
Env map[string]string
// Functions are the template functions expectations start from; nil is
// KEL's. SpecFunctions are added to them.
Functions template.FuncMap
SpecFunctions []resolver.Function
// OnFailure is the spec's onFailure: its stop applies to every
// expectation that doesn't set its own.
OnFailure *spec.OnFailure
// Data is what when:/or: conditions read, such as the object under test.
Data map[string]any
// Contexts are added to every expectation's env: ${{ ecosystem.… }}.
Contexts spec.Contexts
// TemplateData is what templates and CEL read besides env, by key, such
// as the ecosystem's connection details under ecosystem.
TemplateData map[string]any
}
Options configure a Runner.
type Result ¶
type Result struct {
Name string
SpecPath string
Context string
Cluster string
StartedAt time.Time
Cases []CaseResult
Elapsed time.Duration
Command string
// StopReason is non-empty when the run stopped before all expectations ran.
// Values: "max-failures" (the --max-failures cap was hit) or "step" (an
// expectation declared onFailure.stop). Empty means the run completed.
StopReason string
// StoppedAfter is the number of failures observed when the run stopped.
// Zero when StopReason is empty.
StoppedAfter int
Planned int // the number of expectations declared in the suite
// Warnings are the suite onFailure's failures; like a case's, they never
// change the result.
Warnings []string
// SetupFailure is set when the environment or a prepare step failed and
// stopped the run. The expectations that ran before it are in Cases.
SetupFailure *SetupFailure
// Imports contains the results of imported E2E suites.
Imports ImportResults `json:"-"`
// Caller identifies the application or integration that invoked jig.
// It is empty when jig is run directly through its CLI.
Caller string `json:"caller,omitempty" yaml:"caller,omitempty"`
}
Result holds the outcome of a complete E2E run. It is returned by Run and consumed by inrun push to embed verification metadata into OCI annotations.
func (*Result) CallerName ¶
CallerName returns the invoking application, defaulting to "jig".
func (*Result) Duration ¶
Duration returns the total elapsed time as a human-readable string (e.g. "45s").
func (*Result) DurationWithImports ¶
DurationWithImports returns the total elapsed time as a human-readable string.
func (*Result) ExtraAttempts ¶
ExtraAttempts returns the total attempts beyond the first, across all cases. A suite where one case passed on try 2 returns 1.
func (*Result) Summary ¶
Summary returns a one-line result string, e.g. "3 of 4 passed, 1 skipped (45s)".
func (*Result) WithImports ¶
WithImports returns true when the suite has imported E2E suites.
func (*Result) WithImportsDuration ¶
WithImports returns the total elapsed time across this suite and all imports.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner runs expectations, group by group, keeping the results, the failure count and the stop across groups: a run calls Run once per after: group, between its steps.
func (*Runner) Record ¶
func (r *Runner) Record(c CaseResult)
Record adds a result made outside the expectations, such as a guard's, counting it as a failure when it didn't pass.
type SetupFailure ¶
SetupFailure is what stopped a run before its expectations could finish: At is "environment" or the prepare step's name, Err why.
type StepResult ¶
type StepResult struct {
Attempts int // attempts actually run
Configured int // 1 + retry count; 1 when no retry is configured
Skipped bool // when:/or: gate not met; the expectation did not run
}
StepResult is what one expectation's run produced: the outcome plus how many attempts it took and how many were configured. The runner copies these into the case result for the report.
type SuitePostOptions ¶
type SuitePostOptions struct {
Env map[string]string
WorkDir string
CS kubernetes.Interface
Cfg *rest.Config
// Functions are the template functions the block starts from; nil is
// KEL's. SpecFunctions are added to them.
Functions template.FuncMap
SpecFunctions []resolver.Function
// Contexts and TemplateData are the run's, as in Options.
Contexts spec.Contexts
TemplateData map[string]any
}
SuitePostOptions is what a spec-level post block needs: the spec's env and functions, and the cluster it runs against.