reactloopstests

package
v1.4.4-beta13 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionHandlerCapture

type ActionHandlerCapture struct {
	Called      bool
	Action      *aicommon.Action
	Operator    *reactloops.LoopActionHandlerOperator
	FeedbackMsg string
	Failed      bool
	FailedMsg   string
	Continued   bool
	Terminated  bool
	CalledCount int
}

ActionHandlerCapture captures information about action handler execution

type ActionTestFramework

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

ActionTestFramework provides utilities for testing ReAct loop actions

func NewActionTestFramework

func NewActionTestFramework(t *testing.T, loopName string, options ...reactloops.ReActLoopOption) *ActionTestFramework

NewActionTestFramework creates a new action testing framework

func NewActionTestFrameworkEx

func NewActionTestFrameworkEx(
	t *testing.T,
	loopName string,
	loopOptions []reactloops.ReActLoopOption,
	aiConfigOptions []aicommon.ConfigOption,
) *ActionTestFramework

NewActionTestFrameworkEx creates a new action testing framework with extended options It supports both ReActLoop options and AI config options

func (*ActionTestFramework) AssertActionCalled

func (f *ActionTestFramework) AssertActionCalled(actionName string)

AssertActionCalled asserts that an action was called

func (*ActionTestFramework) AssertActionFailed

func (f *ActionTestFramework) AssertActionFailed(actionName string)

AssertActionFailed asserts that an action failed

func (*ActionTestFramework) AssertActionNotCalled

func (f *ActionTestFramework) AssertActionNotCalled(actionName string)

AssertActionNotCalled asserts that an action was not called

func (*ActionTestFramework) AssertActionSucceeded

func (f *ActionTestFramework) AssertActionSucceeded(actionName string)

AssertActionSucceeded asserts that an action succeeded (continued or terminated without failure)

func (*ActionTestFramework) AssertFeedbackContains

func (f *ActionTestFramework) AssertFeedbackContains(actionName string, substring string)

AssertFeedbackContains asserts that the feedback message contains a substring

func (*ActionTestFramework) AssertLoopContextInt

func (f *ActionTestFramework) AssertLoopContextInt(key string, expectedValue int)

AssertLoopContextInt asserts an int value in the loop context

func (*ActionTestFramework) AssertLoopContextValue

func (f *ActionTestFramework) AssertLoopContextValue(key string, expectedValue interface{})

AssertLoopContextValue asserts a value in the loop context

func (*ActionTestFramework) ExecuteAction

func (f *ActionTestFramework) ExecuteAction(actionName string, params map[string]interface{}) error

ExecuteAction executes a specific action with given parameters

func (*ActionTestFramework) ExecuteActionWithTimeout

func (f *ActionTestFramework) ExecuteActionWithTimeout(actionName string, params map[string]interface{}, timeout time.Duration) error

ExecuteActionWithTimeout executes a specific action with given parameters and timeout If timeout is 0 or negative, it uses context.Background() (no timeout) If timeout > 0, it creates a context with the specified timeout

func (*ActionTestFramework) GetAICallCount

func (f *ActionTestFramework) GetAICallCount() int

GetAICallCount returns the number of AI calls made

func (*ActionTestFramework) GetActionCapture

func (f *ActionTestFramework) GetActionCapture(actionName string) *ActionHandlerCapture

GetActionCapture returns the capture information for a specific action

func (*ActionTestFramework) GetLoop

GetLoop returns the underlying ReActLoop for custom operations

func (*ActionTestFramework) GetTask

GetTask returns the captured task

func (*ActionTestFramework) RegisterTestAction

func (f *ActionTestFramework) RegisterTestAction(
	actionName string,
	description string,
	verifier func(loop *reactloops.ReActLoop, action *aicommon.Action) error,
	handler func(loop *reactloops.ReActLoop, action *aicommon.Action, op *reactloops.LoopActionHandlerOperator),
)

RegisterTestAction registers an action for testing and captures its execution

func (*ActionTestFramework) Reset

func (f *ActionTestFramework) Reset()

Reset resets all captured state (useful for multiple test cases)

Jump to

Keyboard shortcuts

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