assert

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package assert evaluates declared assertions against a value. It is shared: the engine runs it as a post-step for provider nodes, and looping nodes (poll, sse) call it per attempt/event. It is a plain package function, not a method on a context — the way json.Marshal is.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Op

type Op string

Op is a comparison operator.

const (
	OpEquals      Op = "equals"
	OpNotEquals   Op = "not_equals"
	OpContains    Op = "contains"
	OpNotContains Op = "not_contains"
	OpStartsWith  Op = "starts_with"
	OpEndsWith    Op = "ends_with"
	OpRegex       Op = "regex"
	OpEmpty       Op = "empty"
	OpNotEmpty    Op = "not_empty"
	OpGreaterThan Op = "gt"
	OpLessThan    Op = "lt"
	OpGTE         Op = "gte"
	OpLTE         Op = "lte"
	OpBetween     Op = "between"
	OpExists      Op = "exists"
)

Built-in operators.

type Result

type Result struct {
	Spec   Spec
	Actual value.Value
	Passed bool
	Err    string
}

Result is one assertion's outcome.

type Results

type Results []Result

Results is the outcome of evaluating a set of specs.

func Run

func Run(v value.Value, specs []Spec) Results

Run evaluates every spec against v and returns one Result each.

func (Results) AllPassed

func (rs Results) AllPassed() bool

AllPassed reports whether every assertion passed.

type Spec

type Spec struct {
	Path     string      `json:"path"`
	Op       Op          `json:"op"`
	Expected value.Value `json:"expected"`
}

Spec is one declared assertion: extract Path from the value, compare it with Op against Expected. Expected is boxed at decode, so re-evaluating the same spec (poll attempts, SSE events, loop iterations) never re-parses it.

Jump to

Keyboard shortcuts

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