t_tree

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ITestingAware

type ITestingAware interface {
	OnTestingInit(t testing_ctx.T)
}

type Node

type Node[Q any, R any, TC any] struct {
	ID            string
	ParentID      string          // only required in detached mode
	ParentNode    *Node[Q, R, TC] // optional with ParentID. If both set, they must match
	InheritAssert bool            // by default assert is not inherited
	Description   string
	Tags          []string // for grouping

	Run    func(t testing_ctx.T, tctx *TC, req *Q) (*R, error)
	Setup  func(t testing_ctx.T, tctx *TC, req *Q) (*TC, *Q)
	Assert func(t testing_ctx.T, tctx *TC, req *Q, res *R, err error)

	Children []*Node[Q, R, TC]
}

Node defines a node in the tree of testing cases Q: request R: response TC: testing context

type NodePath added in v0.0.19

type NodePath[Q any, R any, TC any] []*Node[Q, R, TC]

func (NodePath[Q, R, TC]) Assert added in v0.0.19

func (c NodePath[Q, R, TC]) Assert(t testing_ctx.T, tctx *TC, req *Q, resp *R, err error)

func (NodePath[Q, R, TC]) Parent added in v0.0.25

func (c NodePath[Q, R, TC]) Parent() NodePath[Q, R, TC]

func (NodePath[Q, R, TC]) Run added in v0.0.19

func (c NodePath[Q, R, TC]) Run(t testing_ctx.T)

func (NodePath[Q, R, TC]) Runner added in v0.0.19

func (c NodePath[Q, R, TC]) Runner() func(t testing_ctx.T, tctx *TC, req *Q) (*R, error)

func (NodePath[Q, R, TC]) Setup added in v0.0.19

func (c NodePath[Q, R, TC]) Setup(t testing_ctx.T) (*Q, *TC)

type PanicError added in v0.0.24

type PanicError struct {
	Arg   interface{}
	Stack []byte
}

func (*PanicError) Error added in v0.0.24

func (c *PanicError) Error() string

func (*PanicError) Unwrap added in v0.0.24

func (c *PanicError) Unwrap() error

type Tree

type Tree[Q any, R any, TC any] struct {
	Root *Node[Q, R, TC]
	// contains filtered or unexported fields
}

func Build

func Build[Q any, R any, TC any](root *Node[Q, R, TC], nodes []*Node[Q, R, TC]) (*Tree[Q, R, TC], error)

Build builds a tree from a list of nodes. The root node is the node without parent If multiple nodes defined no

func MustBuild

func MustBuild[Q any, R any, TC any](root *Node[Q, R, TC], nodes []*Node[Q, R, TC]) *Tree[Q, R, TC]

func (*Tree[Q, R, TC]) FindNode

func (c *Tree[Q, R, TC]) FindNode(id string) *Node[Q, R, TC]

func (*Tree[Q, R, TC]) GetNodePath added in v0.0.19

func (c *Tree[Q, R, TC]) GetNodePath(node *Node[Q, R, TC]) NodePath[Q, R, TC]

func (*Tree[Q, R, TC]) GetPath added in v0.0.19

func (c *Tree[Q, R, TC]) GetPath(id string) NodePath[Q, R, TC]

func (*Tree[Q, R, TC]) Run

func (c *Tree[Q, R, TC]) Run(t testing_ctx.T)

func (*Tree[Q, R, TC]) RunNode

func (c *Tree[Q, R, TC]) RunNode(t testing_ctx.T, node *Node[Q, R, TC])

func (*Tree[Q, R, TC]) ServeSVG added in v0.0.18

func (t *Tree[Q, R, TC]) ServeSVG() error

ServeSVG generates an SVG representation of the tree and serves it on a local server

func (*Tree[Q, R, TC]) ToDecisionTree added in v0.0.18

func (t *Tree[Q, R, TC]) ToDecisionTree() *decision_tree.Node

ToDecisionTree converts a t_tree.Tree to a decision_tree.Node This allows us to leverage the visualization capabilities of the decision_tree package

func (*Tree[Q, R, TC]) ToMermaid

func (c *Tree[Q, R, TC]) ToMermaid() string

ToMermaid generates a Mermaid flowchart diagram representation of the tree. The diagram uses TD (top-down) layout with nodes and connections. Returns a string in Mermaid syntax that can be rendered in Markdown.

func (*Tree[Q, R, TC]) ToSVG added in v0.0.18

func (t *Tree[Q, R, TC]) ToSVG() string

ToSVG generates an SVG representation of the tree

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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