cli: make bundled help self-describing
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user