Skip to main content

Asset Database Testing Guide

Summary

Source-backed inventory of what actually tests the Asset Service persistence today, and a clearly separated catalog of database coverage that would be safe to add. The only existing evidence is a smoke script that exercises persistence indirectly over HTTP.

Audience

Backend engineers, database reviewers, architects, QA, support, operations, security reviewers, and product owners.

Overview

The single source-tracked test asset is a smoke script, smoke-asset.ps1, that drives the service over HTTP and asserts on responses. It touches persistence only indirectly. There is no dedicated EF/DbContext unit test, no repository test, no migration test, no concurrency test, and no transaction test in source. The recommended coverage below is future work; none of it exists yet and nothing here should be read as claiming otherwise.

Confirmed persistence behavior

  • Existing evidence: smoke script. smoke-asset.ps1 exercises the service through its HTTP surface with flags for the major slices: -Workflow, -Documents, -Notifications, -Clearance, -Compatibility, -Gateway, -Backfill, -Parity, and -Cutover. Its assertions verify persistence outcomes indirectly (through API responses), not by asserting against the database directly.
  • No dedicated database-level tests in source. There is no EF/DbContext unit test, no repository test, no migration up/down test, no transaction test, and no concurrency test present.

The following are suggestions for safe future tests. They do not exist today. None should ever be run against a production database.

  • Unit (DbContext mapping) tests: column mappings, owned value-object mappings, enum-to-string conversions, primary keys, default values.
  • Repository tests: lookups by id and by compatibility id, tenant-filtered existence checks, include of history and document children.
  • EF integration tests: required cascade relationships, aggregate query filters, tenant isolation, and that non-filtered messaging tables behave as intended.
  • Migration tests: apply the initial migration up and roll it back down against a disposable database.
  • Transaction tests: confirm that aggregate state, history, document references, audit, timeline, and outbox commit together within one save.
  • Concurrency tests: exercise two concurrent lifecycle transitions and two concurrent assigns to characterize behavior in the absence of a concurrency token.
  • Security tests: verify tenant isolation under differing tenant contexts and the elevated-context filter bypass.
  • Uniqueness/race tests: the application-layer per-tenant asset-code uniqueness check under concurrent creation, and the compatibility-id unique index.
  • Backfill tests: idempotent re-run producing no changes, deterministic identity mapping, upsert-only with no deletes, and no event emission.
  • Retention tests: guarded hard delete with cascade, and document-reference removal leaving the external blob in place.
  • Query-performance checks: the capped list and workspace reads, and the indexed status/type/workflow/compatibility lookups.

Classification

Implemented indirect smoke coverage only; all database-level test types are recommended future work.

Requires confirmation

  • Target coverage levels and which test tiers (unit, repository, EF integration, migration, transaction, concurrency, security, backfill) are in scope for the service.
  • The disposable-database strategy for integration and migration tests.

Diagram

See Also

Keywords

  • Asset database testing
  • Persistence tests
  • Draft database documentation

Source References

  • microservices/scripts/smoke-asset.ps1
  • microservices/src/asset-service/Infrastructure/AssetDbContext.cs
  • microservices/src/asset-service/Domain/Asset/Asset.cs

Revision Information

  • Status: Draft
  • Last reviewed: 2026-07-17
  • Review cycle: Quarterly