refactor(project): clean up project handler tests to use common utils - #2256
refactor(project): clean up project handler tests to use common utils#2256Hweinstock wants to merge 4 commits into
Conversation
|
Claude Security Review: no high-confidence findings. (run) |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
Nice consolidation. Extracting inTempDirectory and initProject into src/testing/ and replacing the per-file originalCwd/tempDirectories boilerplate with a cleanups list makes the tests substantially shorter and more consistent. The refactor is test-only, no production code changes, and it stays on the "real temp directory over fs mock" side of the mocking guidance.
A few minor observations — none blocking:
src/testing/projects.ts: ifroot.route([... "create" ...])throws insideinitProject, the temp directory created byinTempDirectoryis leaked and cwd isn't restored, since the returnedcleanuphasn't reached the caller yet. The previous pattern pushed the temp dir onto a shared array beforerun, soafterEachstill cleaned it. Only matters for failure paths ofproject createitself, but atry { … } catch { await cleanup(); throw }insideinitProjectwould preserve the old behavior.src/handlers/project/project.test.ts: theconst cleanups = []declaration now sits below two tests that reference it (project status requires an AgentCore project,project dev requires an AgentCore project). Works because the test bodies run after module init, but it reads a little surprising — worth hoisting the declaration to the top of the file next to the other module-level state.- Files with both
afterEach(cleanupScreens)andafterEach(() => Promise.all(cleanups…))rely on registration-order execution. That's what Bun does today, and it matches the prior behavior, so fine as-is — just something to keep in mind if we ever move to another runner.
Happy to see this land.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor #2256 +/- ##
============================================
- Coverage 97.04% 97.04% -0.01%
============================================
Files 566 566
Lines 39353 39334 -19
============================================
- Hits 38190 38171 -19
Misses 1163 1163 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Claude Security Review: no high-confidence findings. (run) |
4f64b0a to
a11d91b
Compare
|
Claude Security Review: no high-confidence findings. (run) |
|
Claude Security Review: no high-confidence findings. (run) |
a11d91b to
2e2c8d4
Compare
|
Claude Security Review: no high-confidence findings. (run) |
Problem
Each project test redefined their own version of the same utilities.
Examples:
agentcore-cli/src/handlers/project/add/runtime/index.test.ts
Line 43 in b18bb4b
Solution
src/testing/projects.ts.Future Work