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

Function TestRunSetupCreatesConfigAndHooks

cmd/setup_run_test.go:48–84  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestRunSetupCreatesConfigAndHooks(t *testing.T) {
49 root := t.TempDir()
50 if err := os.MkdirAll(filepath.Join(root, ".git"), 0o755); err != nil {
51 t.Fatal(err)
52 }
53 if err := os.WriteFile(filepath.Join(root, "main.go"), []byte("package main\n"), 0o644); err != nil {
54 t.Fatal(err)
55 }
56 if err := os.WriteFile(filepath.Join(root, "worker.go"), []byte("package main\n"), 0o644); err != nil {
57 t.Fatal(err)
58 }
59
60 first := captureOutput(func() { RunSetup([]string{root}, ".") })
61 if !strings.Contains(first, "Config: created") || !strings.Contains(first, "Hooks: created") {
62 t.Fatalf("unexpected first setup output:\n%s", first)
63 }
64
65 cfgPath := filepath.Join(root, ".codemap", "config.json")
66 if _, err := os.Stat(cfgPath); err != nil {
67 t.Fatalf("expected config file to exist: %v", err)
68 }
69 settingsPath := filepath.Join(root, ".claude", "settings.local.json")
70 if _, err := os.Stat(settingsPath); err != nil {
71 t.Fatalf("expected settings file to exist: %v", err)
72 }
73
74 second := captureOutput(func() { RunSetup([]string{root}, ".") })
75 if !strings.Contains(second, "Config: already exists") || !strings.Contains(second, "Hooks: already configured") {
76 t.Fatalf("unexpected second setup output:\n%s", second)
77 }
78
79 settings := readSettingsFile(t, settingsPath)
80 hooks := readHooksMap(t, settings)
81 if len(hooks) == 0 {
82 t.Fatal("expected hooks to be configured")
83 }
84}

Callers

nothing calls this directly

Calls 4

captureOutputFunction · 0.85
RunSetupFunction · 0.85
readSettingsFileFunction · 0.85
readHooksMapFunction · 0.85

Tested by

no test coverage detected