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

Function TestInMemoryStore_List

pkg/memory/logic/store_test.go:68–150  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestInMemoryStore_List(t *testing.T) {
69 store := NewInMemoryStore()
70 defer func() { _ = store.Close() }()
71
72 ctx := context.Background()
73 namespace := "user:123"
74
75 // 创建多个 Memory
76 memories := []*LogicMemory{
77 {
78 ID: "mem-1",
79 Namespace: namespace,
80 Scope: ScopeUser,
81 Type: "preference",
82 Key: "tone",
83 Provenance: &memory.MemoryProvenance{
84 Confidence: 0.9,
85 },
86 },
87 {
88 ID: "mem-2",
89 Namespace: namespace,
90 Scope: ScopeSession,
91 Type: "behavior",
92 Key: "edit_pattern",
93 Provenance: &memory.MemoryProvenance{
94 Confidence: 0.7,
95 },
96 },
97 {
98 ID: "mem-3",
99 Namespace: namespace,
100 Scope: ScopeUser,
101 Type: "preference",
102 Key: "style",
103 Provenance: &memory.MemoryProvenance{
104 Confidence: 0.5,
105 },
106 },
107 {
108 ID: "mem-4",
109 Namespace: "user:456", // 不同 namespace
110 Scope: ScopeUser,
111 Type: "preference",
112 Key: "tone",
113 Provenance: &memory.MemoryProvenance{
114 Confidence: 0.8,
115 },
116 },
117 }
118
119 for _, m := range memories {
120 require.NoError(t, store.Save(ctx, m))
121 }
122
123 // List all in namespace
124 result, err := store.List(ctx, namespace)
125 require.NoError(t, err)

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
SaveMethod · 0.95
ListMethod · 0.95
WithTypeFunction · 0.85
WithScopeFunction · 0.85
WithMinConfidenceFunction · 0.85
WithTopKFunction · 0.85
WithOrderByFunction · 0.85
NewInMemoryStoreFunction · 0.70
LenMethod · 0.65

Tested by

no test coverage detected