MCPcopy Create free account
hub / github.com/JordanCoin/codemap / TestGetProjectStatsAndHandleListProjects

Function TestGetProjectStatsAndHandleListProjects

mcp/main_test.go:43–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestGetProjectStatsAndHandleListProjects(t *testing.T) {
44 parent := t.TempDir()
45 alpha := filepath.Join(parent, "alpha")
46 beta := filepath.Join(parent, "beta")
47 if err := os.MkdirAll(filepath.Join(alpha, ".git"), 0o755); err != nil {
48 t.Fatal(err)
49 }
50 if err := os.MkdirAll(beta, 0o755); err != nil {
51 t.Fatal(err)
52 }
53 if err := os.WriteFile(filepath.Join(alpha, "main.go"), []byte("package main\n"), 0o644); err != nil {
54 t.Fatal(err)
55 }
56 if err := os.WriteFile(filepath.Join(beta, "app.py"), []byte("print('ok')\n"), 0o644); err != nil {
57 t.Fatal(err)
58 }
59
60 stats := getProjectStats(alpha)
61 if !strings.Contains(stats, "1 files") || !strings.Contains(stats, "Go") || !strings.Contains(stats, "[git]") {
62 t.Fatalf("unexpected project stats: %s", stats)
63 }
64
65 res, _, err := handleListProjects(context.Background(), nil, ListProjectsInput{Path: parent, Pattern: "alp"})
66 if err != nil {
67 t.Fatalf("handleListProjects error: %v", err)
68 }
69 out := resultText(t, res)
70 if !strings.Contains(out, "Projects matching 'alp'") || !strings.Contains(out, "alpha/") || strings.Contains(out, "beta/") {
71 t.Fatalf("unexpected list_projects output:\n%s", out)
72 }
73}
74
75func TestHandleFindFileAndStatus(t *testing.T) {
76 root := t.TempDir()

Callers

nothing calls this directly

Calls 3

getProjectStatsFunction · 0.85
handleListProjectsFunction · 0.85
resultTextFunction · 0.85

Tested by

no test coverage detected