testutil

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertContains

func AssertContains(t *testing.T, haystack, needle string, msgAndArgs ...interface{})

AssertContains asserts that a string contains a substring

func AssertEqual

func AssertEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{})

AssertEqual asserts that two values are equal

func AssertError

func AssertError(t *testing.T, err error, msgAndArgs ...interface{})

AssertError asserts that an error is not nil

func AssertEventually

func AssertEventually(t *testing.T, condition func() bool, timeout time.Duration, msgAndArgs ...interface{})

AssertEventually asserts that a condition is eventually true

func AssertFalse

func AssertFalse(t *testing.T, value bool, msgAndArgs ...interface{})

AssertFalse asserts that a value is false

func AssertNil

func AssertNil(t *testing.T, value interface{}, msgAndArgs ...interface{})

AssertNil asserts that a value is nil

func AssertNoError

func AssertNoError(t *testing.T, err error, msgAndArgs ...interface{})

AssertNoError asserts that an error is nil

func AssertNotNil

func AssertNotNil(t *testing.T, value interface{}, msgAndArgs ...interface{})

AssertNotNil asserts that a value is not nil

func AssertTrue

func AssertTrue(t *testing.T, value bool, msgAndArgs ...interface{})

AssertTrue asserts that a value is true

func RunParallel

func RunParallel(t *testing.T, tests map[string]func(t *testing.T))

RunParallel runs test functions in parallel

func WaitForCondition

func WaitForCondition(ctx context.Context, condition func() bool, interval time.Duration) error

WaitForCondition waits for a condition to be true

Types

type TestAgentConfig

type TestAgentConfig struct {
	Name         string
	SystemPrompt string
	Tools        []string
	MaxIter      int
}

CreateTestAgent creates a test agent with mocks

func DefaultTestAgentConfig

func DefaultTestAgentConfig() TestAgentConfig

DefaultTestAgentConfig returns default test agent config

type TestAppContext

type TestAppContext struct {
	UserID   string
	UserName string
	Metadata map[string]interface{}
}

TestAppContext is a simple application context for testing

type TestContext

type TestContext struct {
	Ctx          context.Context
	Cancel       context.CancelFunc
	State        *state.AgentState
	Store        store.Store
	Checkpointer checkpoint.Checkpointer
	MockLLM      *mocks.MockLLMClient
	MockTools    map[string]*mocks.MockTool
	T            *testing.T
}

TestContext provides a complete test environment

func NewTestContext

func NewTestContext(t *testing.T) *TestContext

NewTestContext creates a new test context

func (*TestContext) AddMockTool

func (tc *TestContext) AddMockTool(name, description string) *mocks.MockTool

AddMockTool adds a mock tool to the context

func (*TestContext) CreateRuntime

func (tc *TestContext) CreateRuntime(sessionID string) *execution.Runtime[TestAppContext, *state.AgentState]

CreateRuntime creates a test runtime

Jump to

Keyboard shortcuts

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