MCPcopy Create free account
hub / github.com/astercloud/aster / TestWorkingMemoryBasic

Function TestWorkingMemoryBasic

examples/memory-working/verify_test.go:12–47  ·  view source on GitHub ↗

TestWorkingMemoryBasic 验证 Working Memory 基本功能

(t *testing.T)

Source from the content-addressed store, hash-verified

10
11// TestWorkingMemoryBasic 验证 Working Memory 基本功能
12func TestWorkingMemoryBasic(t *testing.T) {
13 ctx := context.Background()
14 backend := backends.NewStateBackend()
15
16 // 创建 Working Memory 管理器
17 manager, err := memory.NewWorkingMemoryManager(&memory.WorkingMemoryConfig{
18 Backend: backend,
19 BasePath: "/working_memory/",
20 Scope: memory.ScopeThread,
21 })
22 if err != nil {
23 t.Fatalf("create manager: %v", err)
24 }
25
26 threadID := "test-thread"
27 resourceID := "test-resource"
28
29 // 更新 Working Memory
30 testContent := "# Test Profile\nName: Test User"
31 err = manager.Update(ctx, threadID, resourceID, testContent)
32 if err != nil {
33 t.Fatalf("update: %v", err)
34 }
35
36 // 读取
37 content, err := manager.Get(ctx, threadID, resourceID)
38 if err != nil {
39 t.Fatalf("get: %v", err)
40 }
41
42 if content != testContent {
43 t.Errorf("expected %q, got %q", testContent, content)
44 }
45
46 t.Log("✓ Working Memory 基本功能验证通过")
47}
48
49// TestWorkingMemoryScope 验证作用域隔离
50func TestWorkingMemoryScope(t *testing.T) {

Callers

nothing calls this directly

Calls 5

UpdateMethod · 0.95
GetMethod · 0.95
NewStateBackendFunction · 0.92
NewWorkingMemoryManagerFunction · 0.92
LogMethod · 0.65

Tested by

no test coverage detected