writeWatchState writes a watch.State JSON file to /.codemap/state.json and a PID file pointing to the current process so IsRunning returns true.
(t *testing.T, root string, state watch.State)
| 801 | // writeWatchState writes a watch.State JSON file to <root>/.codemap/state.json |
| 802 | // and a PID file pointing to the current process so IsRunning returns true. |
| 803 | func writeWatchState(t *testing.T, root string, state watch.State) { |
| 804 | t.Helper() |
| 805 | codemapDir := filepath.Join(root, ".codemap") |
| 806 | if err := os.MkdirAll(codemapDir, 0755); err != nil { |
| 807 | t.Fatal(err) |
| 808 | } |
| 809 | data, err := json.Marshal(state) |
| 810 | if err != nil { |
| 811 | t.Fatal(err) |
| 812 | } |
| 813 | if err := os.WriteFile(filepath.Join(codemapDir, "state.json"), data, 0644); err != nil { |
| 814 | t.Fatal(err) |
| 815 | } |
| 816 | if err := watch.WritePID(root); err != nil { |
| 817 | t.Fatal(err) |
| 818 | } |
| 819 | t.Cleanup(func() { watch.RemovePID(root) }) |
| 820 | } |
| 821 | |
| 822 | // TestGetLastSessionEvents verifies that the 20-line budget is enforced when |
| 823 | // reading the events log, protecting hook startup output from bloating context. |
no test coverage detected