engine

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalResult

func MarshalResult(v interface{}) map[string]interface{}

MarshalResult converts a driver's raw result into a JSON-friendly map.

Types

type AssertionResult

type AssertionResult struct {
	Expression string `json:"expression"`
	Passed     bool   `json:"passed"`
	Message    string `json:"message,omitempty"`
	Error      string `json:"error,omitempty"`
	Actual     string `json:"actual,omitempty"` // what the expression evaluated to
}

AssertionResult captures the outcome of a single assertion.

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context holds the variable store and provides expression evaluation.

func NewContext

func NewContext() *Context

NewContext creates an empty variable context.

func (*Context) All

func (c *Context) All() map[string]interface{}

All returns a copy of all variables for use in expression environments.

func (*Context) EvalBool

func (c *Context) EvalBool(expression string) (bool, error)

EvalBool evaluates an expression string and returns a boolean result.

func (*Context) EvalExpr

func (c *Context) EvalExpr(expression string) (interface{}, error)

EvalExpr evaluates an expression and returns the raw result.

func (*Context) Get

func (c *Context) Get(key string) (interface{}, bool)

Get retrieves a value by key. Supports dot notation.

func (*Context) ResolveInterface

func (c *Context) ResolveInterface(v interface{}) interface{}

ResolveInterface recursively resolves ${var} placeholders in any value.

func (*Context) ResolveString

func (c *Context) ResolveString(input string) string

ResolveString replaces ${var} placeholders in a string with context values.

func (*Context) SaveFromResult

func (c *Context) SaveFromResult(saveMap map[string]string, result map[string]interface{}) error

SaveFromResult extracts values from a driver result using save mappings. Each save mapping is like: token -> response.body.token The expression is evaluated against the driver result merged into context.

func (*Context) Set

func (c *Context) Set(key string, value interface{})

Set stores a value in the context. Supports dot notation for nested paths.

type Driver

type Driver interface {
	Name() string
	Execute(ctx context.Context, stepConfig interface{}, flowCtx *Context, env *config.EnvConfig) (map[string]interface{}, error)
}

Driver is the interface all step drivers must implement.

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine orchestrates flow execution.

func NewEngine

func NewEngine(printer Printer, verbose bool, failFast bool) *Engine

NewEngine creates a new engine with the given options.

func (*Engine) RegisterDriver

func (e *Engine) RegisterDriver(name string, d Driver)

RegisterDriver adds a driver to the engine.

func (*Engine) Run

func (e *Engine) Run(ctx context.Context, flowCfg *config.FlowConfig, env *config.EnvConfig, initVars ...map[string]interface{}) *FlowResult

Run executes a complete flow and returns the result. initVars optionally seeds the variable store before execution.

func (*Engine) SetDryRun

func (e *Engine) SetDryRun(v bool)

SetDryRun enables dry-run mode.

type FlowResult

type FlowResult struct {
	Name     string        `json:"name"`
	Duration time.Duration `json:"duration"`
	Steps    []StepResult  `json:"steps"`
	Passed   int           `json:"passed"`
	Failed   int           `json:"failed"`
	Skipped  int           `json:"skipped"`
	Errored  int           `json:"errored"`
}

FlowResult captures the outcome of an entire flow execution.

func (*FlowResult) Success

func (r *FlowResult) Success() bool

Success returns true if all steps passed or were skipped.

func (*FlowResult) Tally

func (r *FlowResult) Tally()

Tally counts results by status.

type Printer

type Printer interface {
	FlowHeader(name string)
	SectionHeader(name string)
	StepStart(name string, driverType string, stepNum int, totalSteps int)
	StepResult(result *StepResult, stepNum int, totalSteps int, verbose bool)
	SetupStart(description string)
	SetupResult(description string, err error)
	CleanupStart(description string)
	CleanupResult(description string, err error)
}

Printer is the interface for step-by-step output.

type StepDetail

type StepDetail struct {
	// HTTP
	Method       string `json:"method,omitempty"`
	URL          string `json:"url,omitempty"`
	RequestBody  string `json:"request_body,omitempty"`
	StatusCode   int    `json:"status_code,omitempty"`
	ResponseBody string `json:"response_body,omitempty"`
	// DB
	Query  string `json:"query,omitempty"`
	Params string `json:"params,omitempty"`
	// Kafka
	Topic  string `json:"topic,omitempty"`
	Action string `json:"action,omitempty"`
	Match  string `json:"match,omitempty"`
	// Redis
	RedisAction string `json:"redis_action,omitempty"`
	Key         string `json:"key,omitempty"`
	// Shell
	Command string `json:"command,omitempty"`
	Stdout  string `json:"stdout,omitempty"`
	// Saved variables
	Saved map[string]string `json:"saved,omitempty"`
}

StepDetail holds driver-specific info for verbose output.

type StepResult

type StepResult struct {
	Name       string            `json:"name"`
	Status     StepStatus        `json:"status"`
	Duration   time.Duration     `json:"duration"`
	Driver     string            `json:"driver"`
	Assertions []AssertionResult `json:"assertions,omitempty"`
	Error      string            `json:"error,omitempty"`
	SkipReason string            `json:"skip_reason,omitempty"`
	Retries    int               `json:"retries,omitempty"`
	Detail     *StepDetail       `json:"detail,omitempty"` // populated in verbose mode
}

StepResult captures the outcome of a single step.

type StepStatus

type StepStatus string

StepStatus represents the outcome of a step execution.

const (
	StatusPassed  StepStatus = "passed"
	StatusFailed  StepStatus = "failed"
	StatusSkipped StepStatus = "skipped"
	StatusErrored StepStatus = "errored"
)

Jump to

Keyboard shortcuts

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