(t *testing.T)
| 66 | } |
| 67 | |
| 68 | func 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) |
nothing calls this directly
no test coverage detected