ardalis / ardalis/CleanArchitecture

Make the existing SQLite fallback reliable and testable when Docker is unavailable

Open
#1,028 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
18.5k
Forks
3.1k
PR merge metrics
No merged PRs in 30d

Description

## Description

The functional test infrastructure already contains a SQLite fallback when the SQL Server Testcontainer cannot be started.

However, the current behavior is not fully reliable or consistently testable:

- `CustomWebApplicationFactory` falls back to SQLite only for a specific exception type.
- `DockerAvailabilityTests` fails the complete test run when Docker is unavailable, even though the remaining functional tests can use SQLite.
- There is no explicit test verifying that the SQLite fallback is selected and works correctly.
- The active database provider is not clearly visible in the test output.
- The current provider selection relies partly on a global environment variable.

## Desired behavior

- SQL Server through Testcontainers remains the preferred provider for full functional test coverage.
- The functional test suite can run successfully with SQLite when Docker is unavailable or when SQLite is explicitly selected.
- The SQLite path is covered by automated tests.
- Docker-specific coverage does not make the SQLite fallback test run fail.
- The selected database provider is clearly diagnosable.

## Possible approach

- Make the test database provider explicitly selectable, for example through a factory option or dedicated test factory.
- Add a test verifying that `AppDbContext` uses SQLite in fallback mode.
- Add at least one endpoint test that runs against SQLite.
- Change the Docker availability check so that it does not fail a valid SQLite-only test run.
- Keep SQL Server/Testcontainers as the default or CI reference path.

Contributor guide

Open the contributing guide

Research direction

Start with CustomWebApplicationFactory, DockerAvailabilityTests, and AppDbContext to trace provider selection and the Docker-unavailable path. Run the functional tests and add coverage for SQLite provider selection and at least one endpoint. Done means SQLite-only runs succeed, Docker-specific checks do not fail them, and the selected provider is visible in test output.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker, sqlite
Domain
backend, databases, testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.