Skip to content

Consolidate repeated workspace test database, HTTP, and audio fixtures #747

Description

@forkwright

Finding

Harmonia's test surface repeatedly rebuilds the same infrastructure instead of using shared fixtures: migrated in-memory SQLite pools, one-shot HTTP framing/parsing helpers, and synthetic WAV files. These copies are intentionally test-only, but they are not hardcoded expected values whose independence detects production drift; they are setup constructors whose behavior is expected to be identical.

The duplication is broad enough that changing test preconditions now requires a repository-wide search rather than editing one fixture owner.

Verified against main 65644113e47814c87eaba14a6f322820974b8780.

Evidence

  • A normalized function-body scan finds 31 setup-style functions whose body is the same migrated-memory-pool sequence: SqlitePool::connect("sqlite::memory:"), MIGRATOR.run(&pool), return pool. They span Apotheke repositories and tests in Aitesis, Kritike, Eksetasis, Prostheke, Syntaxis, Archon, and others; additional tests inline the same sequence rather than wrapping it.
  • Current GitHub code search for SqlitePool::connect("sqlite::memory:") + MIGRATOR returns the same pattern across many live files, including Apotheke repo tests, Kritike, Aitesis, Syntaxis, Paroche, Exousia, Archon, Komide, and Syndesis.
  • crates/eksetasis/src/test_support.rs:161, komide/src/test_support.rs:92, syndesmos/src/test_support.rs:274, and epignosis/src/test_support.rs:88 each define the same find_subslice HTTP framing helper. Syndesmos and Epignosis also duplicate parse_content_length, and the surrounding local test servers independently implement the same small HTTP fixture protocol.
  • Synthetic RIFF/WAVE construction is repeated in at least five test helpers: akouo-core/src/engine.rs:1024, decode/probe.rs:146, decode/symphonia.rs:290, akouo-android/src/lib.rs:1085, and archon/src/play.rs:76. They all create small valid PCM WAV input so a test can exercise audio code; the fixture bytes are setup, not the expected result under test.

This does not include domain-specific test expectations or wire vectors that are intentionally hardcoded to catch source drift.

Why this matters

Shared setup is part of the test contract. When migration configuration, SQLite pragmas, HTTP framing behavior, TLS/test-provider setup, or valid WAV construction changes, local copies can keep compiling while tests execute under different preconditions.

The duplicated setup also obscures what a test is actually asserting. A local 20-line server or WAV constructor repeated in each module adds maintenance surface without increasing independence of the behavioral expectation.

Desired correction

Establish lightweight reusable test-support owners rather than a large generic test framework:

  • one migrated in-memory Apotheke pool fixture usable by workspace tests;
  • one small local HTTP test-server/framing utility for crates that need scripted request/response fixtures; and
  • one configurable synthetic WAV/PCM fixture builder for audio tests.

Keep expected-value vectors and domain-specific mock behavior local where their independence is load-bearing.

Done when:

  • migrated in-memory pool setup has one implementation consumed across the workspace;
  • the four local HTTP support modules no longer copy framing/search primitives and share a scripted fixture where appropriate;
  • valid WAV construction has one reusable builder with sample-rate/channel/sample controls;
  • shared fixtures expose explicit knobs rather than hidden defaults needed by individual tests; and
  • test-only hardcoded expected values that exist to catch production drift remain independent.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorCode quality and architecture improvementstech-debtTechnical debt and cleanup

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions