(t *testing.T)
| 190 | } |
| 191 | |
| 192 | func TestNewDocCommand_GeneratesAllCommands(t *testing.T) { |
| 193 | t.Parallel() |
| 194 | |
| 195 | outputDir := filepath.Join(t.TempDir(), "cli-docs") |
| 196 | |
| 197 | root := newRootCommand(commandDeps{}) |
| 198 | root.SetArgs([]string{"doc", "--output-dir", outputDir}) |
| 199 | |
| 200 | if err := root.Execute(); err != nil { |
| 201 | t.Fatalf("doc command failed: %v", err) |
| 202 | } |
| 203 | |
| 204 | mdxFiles := findMDX(t, outputDir) |
| 205 | |
| 206 | // Expected files in the nested layout: parents with children render as |
| 207 | // <segment>/index.mdx; leaves render as <segment>.mdx. |
| 208 | expected := []string{ |
| 209 | "agh.mdx", // from agh |
| 210 | "session/index.mdx", // parent with children |
| 211 | "daemon/index.mdx", // parent with children |
| 212 | "tool/index.mdx", // parent with children |
| 213 | "tool/list.mdx", // tool registry operator command |
| 214 | "tool/search.mdx", // tool registry operator command |
| 215 | "tool/info.mdx", // tool registry operator command |
| 216 | "tool/invoke.mdx", // tool registry operator command |
| 217 | "toolsets/index.mdx", // parent with children |
| 218 | "toolsets/list.mdx", // toolset operator command |
| 219 | "toolsets/info.mdx", // toolset operator command |
| 220 | "version.mdx", // leaf without children |
| 221 | } |
| 222 | for _, want := range expected { |
| 223 | if !mdxFiles[want] { |
| 224 | t.Errorf("expected file %q to exist, got files: %v", want, sortedKeys(mdxFiles)) |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | func sortedKeys(m map[string]bool) []string { |
| 230 | keys := make([]string, 0, len(m)) |
nothing calls this directly
no test coverage detected