(t *testing.T)
| 250 | } |
| 251 | |
| 252 | func TestInMemoryStore_GetStats(t *testing.T) { |
| 253 | store := NewInMemoryStore() |
| 254 | defer func() { _ = store.Close() }() |
| 255 | |
| 256 | ctx := context.Background() |
| 257 | namespace := "user:123" |
| 258 | |
| 259 | require.NoError(t, store.Save(ctx, &LogicMemory{ |
| 260 | Namespace: namespace, |
| 261 | Scope: ScopeUser, |
| 262 | Type: "preference", |
| 263 | Key: "key1", |
| 264 | Provenance: &memory.MemoryProvenance{ |
| 265 | Confidence: 0.8, |
| 266 | }, |
| 267 | })) |
| 268 | require.NoError(t, store.Save(ctx, &LogicMemory{ |
| 269 | Namespace: namespace, |
| 270 | Scope: ScopeSession, |
| 271 | Type: "preference", |
| 272 | Key: "key2", |
| 273 | Provenance: &memory.MemoryProvenance{ |
| 274 | Confidence: 0.6, |
| 275 | }, |
| 276 | })) |
| 277 | require.NoError(t, store.Save(ctx, &LogicMemory{ |
| 278 | Namespace: namespace, |
| 279 | Scope: ScopeUser, |
| 280 | Type: "behavior", |
| 281 | Key: "key3", |
| 282 | Provenance: &memory.MemoryProvenance{ |
| 283 | Confidence: 0.7, |
| 284 | }, |
| 285 | })) |
| 286 | |
| 287 | stats, err := store.GetStats(ctx, namespace) |
| 288 | require.NoError(t, err) |
| 289 | assert.Equal(t, 3, stats.TotalCount) |
| 290 | assert.Equal(t, 2, stats.CountByType["preference"]) |
| 291 | assert.Equal(t, 1, stats.CountByType["behavior"]) |
| 292 | assert.Equal(t, 2, stats.CountByScope[ScopeUser]) |
| 293 | assert.Equal(t, 1, stats.CountByScope[ScopeSession]) |
| 294 | assert.InDelta(t, 0.7, stats.AverageConfidence, 0.01) |
| 295 | } |
| 296 | |
| 297 | func TestInMemoryStore_Prune(t *testing.T) { |
| 298 | store := NewInMemoryStore() |
nothing calls this directly
no test coverage detected