Artifact e8463dd04a6acd4832acdaf4c06f98557c06e9b793ae4c50dc8abb3a4468c607:
- File
cli/repo/repo_test.go
— part of check-in
[bb432d52a6]
at
2026-05-04 18:38:36
on branch trunk
— feat(cli/repo): EdgeSync-owned repo subcommand library (#110)
Adds github.com/danmestas/EdgeSync/cli/repo, a kong-compatible command tree for fossil repo operations (ci, co, timeline, diff, cat, config, merge, …) that consumers can embed without importing libfossil/cli.
Cmd and Globals are type aliases of libfossil/cli.RepoCmd and libfossil/cli.Globals. Re-declaring them as wrapper structs would require mirroring ~38 subcommands' worth of kong flags by hand, brittle to libfossil flag changes. Aliases give consumers source-level isolation (no "github.com/danmestas/libfossil/cli" import in their code) while reusing libfossil's tested CLI implementation.
cmd/edgesync/cli.go migrates to the new package as the first consumer. The flag surface, subcommand set, and behavior are unchanged from the end-user perspective.
Closes #105 (user: [email protected], size: 1489) [annotate] [blame] [check-ins using]
package repo_test import ( "strings" "testing" "github.com/alecthomas/kong" repocli "github.com/danmestas/EdgeSync/cli/repo" ) // TestCmdParsesKnownSubcommands proves the re-exported Cmd carries every // fossil repo subcommand kong sees today. We pick a handful of stable // subcommands and confirm kong resolves them without erroring on schema. func TestCmdParsesKnownSubcommands(t *testing.T) { type CLI struct { repocli.Globals Repo repocli.Cmd `cmd:""` } parser, err := kong.New(&CLI{}, kong.Exit(func(int) {})) if err != nil { t.Fatalf("kong.New: %v", err) } subs := []string{"timeline", "ls", "cat", "ci", "co", "diff", "config", "merge"} help := captureHelp(t, parser) for _, s := range subs { if !strings.Contains(help, "repo "+s) { t.Errorf("--help output missing 'repo %s' subcommand:\n%s", s, help) } } } // TestGlobalsHaveRepoFlag verifies the Globals re-export still exposes the // -R / --repo flag downstream consumers depend on. func TestGlobalsHaveRepoFlag(t *testing.T) { type CLI struct { repocli.Globals } parser, err := kong.New(&CLI{}, kong.Exit(func(int) {})) if err != nil { t.Fatalf("kong.New: %v", err) } help := captureHelp(t, parser) if !strings.Contains(help, "--repo") { t.Errorf("--help output missing --repo flag:\n%s", help) } } func captureHelp(t *testing.T, p *kong.Kong) string { t.Helper() var sb strings.Builder p.Stdout = &sb p.Stderr = &sb _, _ = p.Parse([]string{"--help"}) return sb.String() }