Skip to content

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

@sonikro

Description

@sonikro

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 * * * *'

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtTechnical debt items

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions