t_tree

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 4 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(tctx *TC, req *Q) (*R, error)
	Setup  func(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 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]) 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]) 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.

Jump to

Keyboard shortcuts

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