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

Function TestLineageManager_GetLineageDepth

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

Source from the content-addressed store, hash-verified

391}
392
393func TestLineageManager_GetLineageDepth(t *testing.T) {
394 lm := NewLineageManager()
395
396 // Create a chain: mem-1 -> mem-2 -> mem-3 -> mem-4
397 p1 := NewProvenance(SourceUserInput, "session-1")
398 if err := lm.TrackMemoryCreation("mem-1", p1, nil); err != nil {
399 t.Fatalf("TrackMemoryCreation failed: %v", err)
400 }
401
402 p2 := NewProvenance(SourceUserInput, "session-1")
403 if err := lm.TrackMemoryCreation("mem-2", p2, []string{"mem-1"}); err != nil {
404 t.Fatalf("TrackMemoryCreation failed: %v", err)
405 }
406
407 p3 := NewProvenance(SourceUserInput, "session-1")
408 if err := lm.TrackMemoryCreation("mem-3", p3, []string{"mem-2"}); err != nil {
409 t.Fatalf("TrackMemoryCreation failed: %v", err)
410 }
411
412 p4 := NewProvenance(SourceUserInput, "session-1")
413 if err := lm.TrackMemoryCreation("mem-4", p4, []string{"mem-3"}); err != nil {
414 t.Fatalf("TrackMemoryCreation failed: %v", err)
415 }
416
417 tests := []struct {
418 memoryID string
419 wantDepth int
420 }{
421 {"mem-1", 0},
422 {"mem-2", 1},
423 {"mem-3", 2},
424 {"mem-4", 3},
425 }
426
427 for _, tt := range tests {
428 t.Run(tt.memoryID, func(t *testing.T) {
429 depth := lm.GetLineageDepth(tt.memoryID)
430 if depth != tt.wantDepth {
431 t.Errorf("GetLineageDepth(%v) = %v, want %v", tt.memoryID, depth, tt.wantDepth)
432 }
433 })
434 }
435}
436
437func TestLineageManager_GetLineageStats(t *testing.T) {
438 lm := NewLineageManager()

Callers

nothing calls this directly

Calls 5

TrackMemoryCreationMethod · 0.95
GetLineageDepthMethod · 0.95
NewLineageManagerFunction · 0.85
NewProvenanceFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected