sonikro / sonikro/TF2-QuickServer

[Tech Debt] Add missing unit tests for ServerCleanupRoutine, PendingServerCleanupRoutine, and TerminateLongRunningServerRoutine

Open
#272 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

tech-debt
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 file
  • PendingServerCleanupRoutine.ts — no test file
  • TerminateLongRunningServerRoutine.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 makeSut pattern (no shared state)
  • Follow Given/When/Then structure
  • Mock node-schedule with vi.mock("node-schedule") (see ConsumeCreditsRoutine.test.ts for 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 via eventLogger
Expected cron expressions to test:
  • ServerCleanupRoutine: '* * * * *'
  • PendingServerCleanupRoutine: '*/15 * * * *'
  • TerminateLongRunningServerRoutine: '*/30 * * * *'

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.