assert

package
v0.115.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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