package main import ( "strings" "testing" ) // TestRepoMemoryRootHelpShowsWorkflowAndCommands verifies root help describes the workflow and available commands. func TestRepoMemoryRootHelpShowsWorkflowAndCommands(t *testing.T) { t.Parallel() stdout, stderr, exitCode := executeRepoMemoryCommand("--help") if exitCode != 0 { t.Fatalf("expected help exit 0, got %d\nstderr:\n%s\nstdout:\n%s", exitCode, stderr, stdout) } combined := stdout + stderr if !strings.Contains(combined, "Store durable repository knowledge in SQLite") { t.Fatalf("expected root help to explain purpose, got:\n%s", combined) } if !strings.Contains(combined, "Constraints:") { t.Fatalf("expected root help to include constraints section, got:\n%s", combined) } if !strings.Contains(combined, "repo-memory verify --db ~/.codex/data/repo-memory.db --repo /path/to/repo") { t.Fatalf("expected root help to include workflow example, got:\n%s", combined) } } // TestRepoMemoryCommandHelpWorksThroughHelpSubcommand verifies the help subcommand renders command-specific help. func TestRepoMemoryCommandHelpWorksThroughHelpSubcommand(t *testing.T) { t.Parallel() stdout, stderr, exitCode := executeRepoMemoryCommand("help", "add") if exitCode != 0 { t.Fatalf("expected help exit 0, got %d\nstderr:\n%s\nstdout:\n%s", exitCode, stderr, stdout) } combined := stdout + stderr if !strings.Contains(combined, "Insert or update one durable knowledge entry") { t.Fatalf("expected add help summary, got:\n%s", combined) } if !strings.Contains(combined, "Constraints:") { t.Fatalf("expected add help to include constraints section, got:\n%s", combined) } if !strings.Contains(combined, "--kind") || !strings.Contains(combined, "--dep") { t.Fatalf("expected add help to print flags, got:\n%s", combined) } } // TestRepoMemoryCommandHelpWorksWithDashHelp verifies --help renders command-specific help. func TestRepoMemoryCommandHelpWorksWithDashHelp(t *testing.T) { t.Parallel() stdout, stderr, exitCode := executeRepoMemoryCommand("search", "--help") if exitCode != 0 { t.Fatalf("expected help exit 0, got %d\nstderr:\n%s\nstdout:\n%s", exitCode, stderr, stdout) } combined := stdout + stderr if !strings.Contains(combined, "Search stored repository knowledge before a deeper code dive") { t.Fatalf("expected search help summary, got:\n%s", combined) } if !strings.Contains(combined, `--query "actionCode fill"`) { t.Fatalf("expected search help example, got:\n%s", combined) } }