You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Pure functions first.** All business logic lives in pure, side-effect-free functions (`aggregate.ts`, `group.ts`, `output.ts`, `render/` sub-modules). This makes them straightforward to unit-test.
97
-
-**Side effects are isolated.** API calls (`api.ts`, `api-utils.ts`), TTY interaction (`tui.ts`) and CLI parsing (`github-code-search.ts`) are the only side-effectful surfaces. `api-utils.ts` hosts shared retry/pagination helpers that perform network I/O and must not be used outside `api.ts`.
99
+
-**Side effects are isolated.** API calls (`api.ts`, `api-utils.ts`), TTY interaction (`tui.ts`) and CLI parsing (`github-code-search.ts`) are the only side-effectful surfaces. `api-utils.ts` hosts shared retry/pagination helpers that perform network I/O and must not be used outside `api.ts`.`cache.ts` hosts disk-cache helpers that perform filesystem I/O and must not be used outside `api.ts`.
98
100
-**`render.ts` is a façade.** It re-exports everything from `render/` and adds two top-level rendering functions. Consumers import from `render.ts`, not directly from sub-modules.
99
101
-**`types.ts` is the single source of truth** for all shared interfaces. Any new shared type must go there.
100
102
-**No classes** — the codebase uses plain TypeScript interfaces and functions throughout.
@@ -105,6 +107,7 @@ src/
105
107
- Use `describe` / `it` / `expect` from Bun's test runner.
106
108
- Only pure functions need tests; `tui.ts` and `api.ts` are not unit-tested.
107
109
`api-utils.ts` is the exception: its helpers are unit-tested by mocking `globalThis.fetch`.
110
+
`cache.ts` is also tested: it uses the `GITHUB_CODE_SEARCH_CACHE_DIR` env var override to redirect to a temp directory, so tests have no filesystem side effects on the real cache dir.
108
111
- When adding a function to an existing module, add the corresponding test case in the existing `<module>.test.ts`.
109
112
- When creating a new module that contains pure functions, create a companion `<module>.test.ts`.
110
113
- Tests must be self-contained: no network calls, no filesystem side effects.
0 commit comments