Documentation
¶
Overview ¶
============================================================================= 🧪 测试辅助函数 ============================================================================= 提供通用的测试辅助函数和断言
使用方法:
testutil.AssertMessagesEqual(t, expected, actual)
testutil.AssertEventuallyTrue(t, func() bool { return condition }, 5*time.Second)
=============================================================================
Index ¶
- func AssertContains(t *testing.T, s, substr string)
- func AssertError(t *testing.T, err error, msgAndArgs ...any)
- func AssertEventuallyEqual(t *testing.T, expected any, getter func() any, timeout time.Duration)
- func AssertEventuallyTrue(t *testing.T, condition func() bool, timeout time.Duration)
- func AssertJSONEqual(t *testing.T, expected, actual any)
- func AssertMessagesEqual(t *testing.T, expected, actual []types.Message)
- func AssertNoError(t *testing.T, err error, msgAndArgs ...any)
- func AssertNotContains(t *testing.T, s, substr string)
- func AssertToolCallsEqual(t *testing.T, expected, actual []types.ToolCall)
- func CancelledContext() context.Context
- func CollectStreamChunks(ch <-chan llm.StreamChunk) []llm.StreamChunk
- func CollectStreamContent(ch <-chan llm.StreamChunk) string
- func CopyMessages(messages []types.Message) []types.Message
- func CopyToolCalls(toolCalls []types.ToolCall) []types.ToolCall
- func MustJSON(v any) string
- func MustParseJSON[T any](s string) T
- func SendChunksToChannel(chunks []llm.StreamChunk) <-chan llm.StreamChunk
- func TestContext(t *testing.T) context.Context
- func TestContextWithTimeout(t *testing.T, timeout time.Duration) context.Context
- func WaitFor(condition func() bool, timeout time.Duration) bool
- func WaitForChannel[T any](ch <-chan T, timeout time.Duration) (T, bool)
- type BenchmarkHelper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEventuallyEqual ¶
AssertEventuallyEqual 断言值最终相等
func AssertEventuallyTrue ¶
AssertEventuallyTrue 断言条件最终为真
func AssertJSONEqual ¶
AssertJSONEqual 断言两个值的 JSON 表示相等
func AssertMessagesEqual ¶
AssertMessagesEqual 断言两个消息切片相等
func AssertNoError ¶
AssertNoError 断言没有错误
func AssertNotContains ¶
AssertNotContains 断言字符串不包含子串
func AssertToolCallsEqual ¶
AssertToolCallsEqual 断言两个工具调用切片相等
func CollectStreamChunks ¶
func CollectStreamChunks(ch <-chan llm.StreamChunk) []llm.StreamChunk
CollectStreamChunks 收集流式块到切片
func CollectStreamContent ¶
func CollectStreamContent(ch <-chan llm.StreamChunk) string
CollectStreamContent 收集流式内容到字符串
func CopyMessages ¶
CopyMessages 深拷贝消息切片
func CopyToolCalls ¶
CopyToolCalls 深拷贝工具调用切片
func SendChunksToChannel ¶
func SendChunksToChannel(chunks []llm.StreamChunk) <-chan llm.StreamChunk
SendChunksToChannel 发送块到通道
func TestContextWithTimeout ¶
TestContextWithTimeout 返回带自定义超时的测试上下文
Types ¶
type BenchmarkHelper ¶
type BenchmarkHelper struct {
// contains filtered or unexported fields
}
BenchmarkHelper 基准测试辅助结构
func NewBenchmarkHelper ¶
func NewBenchmarkHelper(b *testing.B) *BenchmarkHelper
NewBenchmarkHelper 创建基准测试辅助
func (*BenchmarkHelper) RunParallel ¶
func (h *BenchmarkHelper) RunParallel(body func())
RunParallel 并行运行基准测试
Directories
¶
| Path | Synopsis |
|---|---|
|
============================================================================= 📦 测试数据工厂 - Agent 测试数据 ============================================================================= 提供预定义的 Agent 配置和状态,用于测试 =============================================================================
|
============================================================================= 📦 测试数据工厂 - Agent 测试数据 ============================================================================= 提供预定义的 Agent 配置和状态,用于测试 ============================================================================= |
|
============================================================================= 🧠 MockMemoryManager - 记忆管理器模拟实现 ============================================================================= 用于测试的记忆管理器模拟,支持消息存储和检索
|
============================================================================= 🧠 MockMemoryManager - 记忆管理器模拟实现 ============================================================================= 用于测试的记忆管理器模拟,支持消息存储和检索 |