(t *testing.T)
| 558 | } |
| 559 | |
| 560 | func TestMemoryBundleHelpers(t *testing.T) { |
| 561 | t.Parallel() |
| 562 | |
| 563 | listBundle := memoryListBundle(MemoryListRecord{Memories: []contract.MemoryEntrySummaryPayload{{ |
| 564 | Filename: "prefs.md", |
| 565 | Name: "Prefs", |
| 566 | Type: memcontract.TypeUser, |
| 567 | Description: "saved preference", |
| 568 | Scope: memcontract.ScopeAgent, |
| 569 | AgentTier: memcontract.AgentTierGlobal, |
| 570 | ModTime: fixedTestNow.Add(-time.Minute), |
| 571 | }}}, func() time.Time { return fixedTestNow }) |
| 572 | listHuman, err := listBundle.human() |
| 573 | if err != nil { |
| 574 | t.Fatalf("listBundle.human() error = %v", err) |
| 575 | } |
| 576 | if !strings.Contains(listHuman, "agent:global") { |
| 577 | t.Fatalf("list human = %q, want agent tier label", listHuman) |
| 578 | } |
| 579 | |
| 580 | decisionBundle := memoryMutationBundle("Memory Write", MemoryMutationRecord{ |
| 581 | Decision: testMemoryDecision("dec-1", memcontract.OpAdd), |
| 582 | Applied: true, |
| 583 | }) |
| 584 | decisionHuman, err := decisionBundle.human() |
| 585 | if err != nil { |
| 586 | t.Fatalf("decisionBundle.human() error = %v", err) |
| 587 | } |
| 588 | if !strings.Contains(decisionHuman, "dec-1") || !strings.Contains(decisionHuman, "add") { |
| 589 | t.Fatalf("decision human = %q", decisionHuman) |
| 590 | } |
| 591 | |
| 592 | if memoryScopeLabel(memcontract.ScopeAgent, memcontract.AgentTierWorkspace) != "agent:workspace" { |
| 593 | t.Fatalf( |
| 594 | "memoryScopeLabel(agent workspace) = %q", |
| 595 | memoryScopeLabel(memcontract.ScopeAgent, memcontract.AgentTierWorkspace), |
| 596 | ) |
| 597 | } |
| 598 | if boolStatus(false) != "false" { |
| 599 | t.Fatalf("boolStatus(false) = %q, want false", boolStatus(false)) |
| 600 | } |
| 601 | if _, err := parseOptionalCLIMemoryScope("bogus"); err == nil { |
| 602 | t.Fatal("parseOptionalCLIMemoryScope(bogus) error = nil, want non-nil") |
| 603 | } |
| 604 | if _, err := parseOptionalCLIAgentTier("bogus"); err == nil { |
| 605 | t.Fatal("parseOptionalCLIAgentTier(bogus) error = nil, want non-nil") |
| 606 | } |
| 607 | if _, err := parseOptionalMemoryType("bogus"); err == nil { |
| 608 | t.Fatal("parseOptionalMemoryType(bogus) error = nil, want non-nil") |
| 609 | } |
| 610 | if _, err := resolveMemoryContentValue(newTestDeps(t, &stubClient{}), "@", strings.NewReader("")); err == nil { |
| 611 | t.Fatal("resolveMemoryContentValue(@) error = nil, want non-nil") |
| 612 | } |
| 613 | if _, err := resolveMemoryContentValue(newTestDeps(t, &stubClient{}), "-", strings.NewReader("")); err == nil { |
| 614 | t.Fatal("resolveMemoryContentValue(empty stdin) error = nil, want non-nil") |
| 615 | } |
| 616 | if _, err := readOptionalCommandInput(nil); err != nil { |
| 617 | t.Fatalf("readOptionalCommandInput(nil) error = %v", err) |
nothing calls this directly
no test coverage detected