yao/agent/testutils/testutils.go
Max 889fba942a Enhance testing and context management in assistant operations
- Refactored the Makefile to include new benchmark and memory leak detection tests, improving test coverage.
- Introduced context adjustments in the Create method, allowing hooks to modify context fields such as AssistantID, Connector, Locale, Theme, Route, and Metadata.
- Added a new test scenario to validate context field adjustments, ensuring proper updates during assistant operations.
- Updated test preparation to support optional V8 mode configuration for improved performance during benchmarks.
2025-11-14 12:38:03 +08:00

29 lines
678 B
Go

package testutils
import (
"testing"
"github.com/yaoapp/yao/agent"
"github.com/yaoapp/yao/config"
"github.com/yaoapp/yao/test"
)
// Prepare prepare the test environment with optional V8 mode configuration
// Usage:
//
// testutils.Prepare(t) // standard mode (default)
// testutils.Prepare(t, test.PrepareOption{V8Mode: "performance"}) // performance mode for benchmarks
func Prepare(t *testing.T, opts ...interface{}) {
test.Prepare(t, config.Conf, opts...)
// Load agent
err := agent.Load(config.Conf)
if err != nil {
t.Fatal(err)
}
}
// Clean clean the test environment
func Clean(t *testing.T) {
test.Clean()
}