sonikro / sonikro/TF2-QuickServer
[Tech Debt] Add missing unit tests for ServerCleanupRoutine, PendingServerCleanupRoutine, and TerminateLongRunningServerRoutine
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 19
- Forks
- 10
- Avg merge
- 40m
- Merged PRs (30d)
- 5
Description
Problem
Three of the six job routines in packages/entrypoints/src/jobs/ have no unit tests:
ServerCleanupRoutine.ts— no test filePendingServerCleanupRoutine.ts— no test fileTerminateLongRunningServerRoutine.ts— no test file
The other three routines (ConsumeCreditsRoutine, TerminateServersWithoutCreditRoutine, MonthlyUsageReportRoutine) all have test files.
Fix
Add test files for each missing routine. Each should:
- Use the
makeSutpattern (no shared state) - Follow Given/When/Then structure
- Mock
node-schedulewithvi.mock("node-schedule")(seeConsumeCreditsRoutine.test.tsfor reference) - Verify the job is scheduled with the correct cron expression
- Verify the use case is called when the job fires
- Verify errors are caught, logged via
logger, and reported viaeventLogger
Expected cron expressions to test:
ServerCleanupRoutine:'* * * * *'PendingServerCleanupRoutine:'*/15 * * * *'TerminateLongRunningServerRoutine:'*/30 * * * *'
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read ServerCleanupRoutine.ts, PendingServerCleanupRoutine.ts, and TerminateLongRunningServerRoutine.ts in packages/entrypoints/src/jobs/, then use ConsumeCreditsRoutine.test.ts as the testing reference. Add one test file per routine covering the stated cron expression, use-case invocation, and logger/eventLogger handling for errors, using makeSut, Given/When/Then, and the node-schedule mock.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- backend, testing
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100