Skip to content

test: run reading-profile SQL Server tests on Testcontainers - #1614

Draft
BenjaminMichaelis wants to merge 1 commit into
bmichaelis-reading-time-tracker-8effrom
test/reading-profile-sqlserver-testcontainers
Draft

BenjaminMichaelis wants to merge 1 commit into
bmichaelis-reading-time-tracker-8effrom
test/reading-profile-sqlserver-testcontainers

Conversation

@BenjaminMichaelis

Copy link
Copy Markdown
Member

Summary

Follow-up to #1267. Adds the real-SQL-Server integration tests for the reading profile back, now self-provisioned with Testcontainers instead of an environment variable and a CI service container.

Stacked on #1267: the base is that PR's branch, because these tests exercise code that only exists there. Retarget to main once #1267 merges.

Why a separate PR

In #1267 these tests required ESSENTIALCSHARP_TEST_SQLSERVER and failed when it was missing in CI. The SQL Server service container and that variable existed only on the push-only "Build and test (Ubuntu)" job, so all 8 tests failed on every OS in the PR's CI matrix (8 of 540 per job, nothing else failing).

What it covers

Against a real SQL Server (SQLite serializes writers, so it cannot prove these):

  • concurrent writes for a new user and for an existing user lose no updates
  • the AddUserReadingProfile migration applies, reverts and reapplies; no pending model changes; expected columns
  • foreign key violation (SQL error 547) and cascade delete on user removal
  • reset only removes the caller's row

How it works

  • Testcontainers.MsSql 4.16.0; one container per test class with a pinned image (2022-CU20-ubuntu-22.04), disposed in the class teardown.
  • No env var, no workflow change.
  • Skip vs fail: when no Linux container runtime can be used (local, and the macOS/Windows jobs, whose hosted runners cannot run Linux containers) the tests are skipped with a reason. On GitHub Linux CI (GITHUB_ACTIONS=true and RUNNER_OS=Linux) a failure to start the container fails the tests, so coverage cannot silently disappear.

Testing

  • All 8 tests ran and passed locally against a Podman-backed container (about 60s); full suite 505 passed, 0 failed.
  • Not verified: the skip path (a missing runtime could not be reproduced locally) and the first real run on GitHub Linux CI. Draft until CI confirms.

Review notes

  • Linux CI adds roughly 40-60s for the image pull and container start.
  • The loud-fail condition relies on RUNNER_OS; an explicit workflow env var would be the alternative.
  • Off Linux CI the catch is deliberately broad, so a non-Docker startup error would skip with its message shown instead of failing.

…rver

Self-provisions a pinned SQL Server container per test class instead of requiring
ESSENTIALCSHARP_TEST_SQLSERVER and a CI service container. Skips when no Linux
container runtime is available; fails on GitHub Linux CI so coverage cannot silently drop.

This branch has not been deployed

No deployments
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