Skip to content

test: cover JobRunner endpoint lambdas and polling-service loops#54

Merged
Theauxm merged 2 commits intomainfrom
test/jobrunner-endpoint-coverage
May 5, 2026
Merged

test: cover JobRunner endpoint lambdas and polling-service loops#54
Theauxm merged 2 commits intomainfrom
test/jobrunner-endpoint-coverage

Conversation

@Theauxm
Copy link
Copy Markdown
Member

@Theauxm Theauxm commented May 5, 2026

Summary

Two test files added:

  • `JobRunnerEndpointTests` — stands up an ASP.NET TestServer with `UseTraxJobRunner` and `UseTraxRunEndpoint` mapped, then exercises the happy + exception paths of both endpoint lambdas against an NSubstitute `ITraxRequestHandler`. Adds `Microsoft.AspNetCore.TestHost` and `Microsoft.AspNetCore.Mvc.Testing` to the test project.

  • `PollingServicesTests` — instantiates each of the four scheduler `BackgroundService`s (`ManifestManagerPollingService`, `JobDispatcherPollingService`, `MetadataCleanupPollingService`, `DeadLetterCleanupPollingService`) with a mock service-provider chain and verifies the immediate-cycle behavior, train-throw resilience, and the `JobDispatcherEnabled=false` skip path.

Local line coverage on Trax.Scheduler moves from 88.7% to 91.7%.

The remaining ~3% gap is in postgres-backed code that needs the existing `SchedulerE2EFixture` (postgres) to exercise: `EnqueueJobsJunction`, `DispatchJobsJunction` (uses `FOR UPDATE SKIP LOCKED` which InMemory doesn't support), and `DataContextExtensions`.

Test plan

  • `dotnet test` — passing (11 new across the two files)
  • `dotnet csharpier check .` — clean

Two test files added:
- JobRunnerEndpointTests stands up a TestServer with UseTraxJobRunner
  and UseTraxRunEndpoint mapped, then exercises the happy + exception
  paths of both endpoint lambdas against an NSubstitute
  ITraxRequestHandler. Adds Microsoft.AspNetCore.TestHost +
  Microsoft.AspNetCore.Mvc.Testing to the test project.
- PollingServicesTests instantiates each of the four scheduler
  BackgroundServices (ManifestManager, JobDispatcher, MetadataCleanup,
  DeadLetterCleanup) with a mock service-provider chain and verifies
  the immediate-cycle behavior, train-throw resilience, and the
  JobDispatcherEnabled=false skip path.

Covers the 200 lines of endpoint + polling-service loops that
previously had no direct test coverage. Local line coverage on
Trax.Scheduler moves from 88.7% to 91.7%.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Theauxm Theauxm merged commit d95b7bc into main May 5, 2026
2 checks passed
@Theauxm Theauxm deleted the test/jobrunner-endpoint-coverage branch May 5, 2026 21:29
@traxsharp
Copy link
Copy Markdown

traxsharp Bot commented May 8, 2026

This PR is included in version 1.29.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant