testing_tree_v2

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatGoFunc

func FormatGoFunc(path []string, rootVar string) string

func GenerateTestFile

func GenerateTestFile[Q any, R any, TestingContext ITestingAware, V any](tt *Case[Q, R, TestingContext, V], caseName string, file string, pkg string) error

func GenerateTestFileCode

func GenerateTestFileCode[Q any, R any, TestingContext ITestingAware, V any](tt *Case[Q, R, TestingContext, V], caseName string, pkg string) string

func JoinAsFuncName

func JoinAsFuncName(names []string) string

Types

type Case

type Case[Q any, R any, TestingContext any, V any] struct {
	Name     string
	Variants []V
	Run      func(tctx *TestingContext, req *Q, variant V) (*R, error)
	Setup    func(tctx *TestingContext, req *Q, variant V) (*TestingContext, *Q)
	Assert   func(t *testing.T, tctx *TestingContext, req *Q, variant V, res *R, err error)
	SubCases []*Case[Q, R, TestingContext, V]
}

func (*Case[Q, R, TestingContext, V]) FindPath

func (c *Case[Q, R, TestingContext, V]) FindPath(path []string) (CasePath[Q, R, TestingContext, V], error)

func (*Case[Q, R, TestingContext, V]) FindSubCase

func (c *Case[Q, R, TestingContext, V]) FindSubCase(name string) *Case[Q, R, TestingContext, V]

func (*Case[Q, R, TestingContext, V]) GetAllCases

func (c *Case[Q, R, TestingContext, V]) GetAllCases() []CasePath[Q, R, TestingContext, V]

func (*Case[Q, R, TestingContext, V]) RunAll

func (c *Case[Q, R, TestingContext, V]) RunAll(t *testing.T)

func (*Case[Q, R, TestingContext, V]) RunPath

func (c *Case[Q, R, TestingContext, V]) RunPath(t *testing.T, path []string)

func (*Case[Q, R, TestingContext, V]) RunPathVariant

func (c *Case[Q, R, TestingContext, V]) RunPathVariant(t *testing.T, path []string, v V)

type CasePath

type CasePath[Q any, R any, TestingContext any, V any] []*Case[Q, R, TestingContext, V]

func (CasePath[Q, R, TestingContext, V]) GetPath

func (c CasePath[Q, R, TestingContext, V]) GetPath() []string

func (CasePath[Q, R, TestingContext, V]) GetRunner

func (c CasePath[Q, R, TestingContext, V]) GetRunner() func(tctx *TestingContext, req *Q, variant V) (*R, error)

func (CasePath[Q, R, TestingContext, V]) GetVariants

func (c CasePath[Q, R, TestingContext, V]) GetVariants() []V

func (CasePath[Q, R, TestingContext, V]) Run

func (tt CasePath[Q, R, TestingContext, V]) Run(t *testing.T)

type ITestingAware

type ITestingAware interface {
	OnTestingInit(t *testing.T)
}

Jump to

Keyboard shortcuts

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