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

Function TestLineageManager_GetLineageStats

pkg/memory/lineage_test.go:437–481  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

435}
436
437func TestLineageManager_GetLineageStats(t *testing.T) {
438 lm := NewLineageManager()
439
440 // Create some memories
441 p1 := NewProvenance(SourceUserInput, "session-1")
442 if err := lm.TrackMemoryCreation("mem-1", p1, nil); err != nil { // Root
443 t.Fatalf("TrackMemoryCreation failed: %v", err)
444 }
445
446 p2 := NewProvenance(SourceUserInput, "session-1")
447 if err := lm.TrackMemoryCreation("mem-2", p2, []string{"mem-1"}); err != nil { // Derived
448 t.Fatalf("TrackMemoryCreation failed: %v", err)
449 }
450
451 p3 := NewProvenance(SourceUserInput, "session-2")
452 if err := lm.TrackMemoryCreation("mem-3", p3, nil); err != nil { // Root
453 t.Fatalf("TrackMemoryCreation failed: %v", err)
454 }
455
456 stats := lm.GetLineageStats()
457
458 if stats.TotalMemories != 3 {
459 t.Errorf("TotalMemories = %v, want 3", stats.TotalMemories)
460 }
461
462 if stats.RootMemories != 2 {
463 t.Errorf("RootMemories = %v, want 2", stats.RootMemories)
464 }
465
466 if stats.DerivedMemories != 1 {
467 t.Errorf("DerivedMemories = %v, want 1", stats.DerivedMemories)
468 }
469
470 if stats.MaxDepth != 1 {
471 t.Errorf("MaxDepth = %v, want 1", stats.MaxDepth)
472 }
473
474 if stats.MemoriesBySource["session-1"] != 2 {
475 t.Errorf("MemoriesBySource['session-1'] = %v, want 2", stats.MemoriesBySource["session-1"])
476 }
477
478 if stats.MemoriesBySource["session-2"] != 1 {
479 t.Errorf("MemoriesBySource['session-2'] = %v, want 1", stats.MemoriesBySource["session-2"])
480 }
481}

Callers

nothing calls this directly

Calls 4

TrackMemoryCreationMethod · 0.95
GetLineageStatsMethod · 0.95
NewLineageManagerFunction · 0.85
NewProvenanceFunction · 0.85

Tested by

no test coverage detected