Skip to content

Tests: split tests/ into unit/ + integration/ subtrees #295

@pathosDev

Description

@pathosDev

Spawned from the coverage analysis after the chat-sample sweep.
Hygiene refactor — no behavioural change, no new tests, no
removed tests.

The gap

tests/integration/ is referenced conceptually but empty:

tests/unit/         164 test files
tests/integration/    0 files
tests/multi-node/  ~14 test files (cluster, multi-process)
tests/smoke/         1 file (cross-runtime smoke)
tests/util/          3 helper files

The current convention is "everything that runs in-process under
Bun goes in tests/unit/", but several files already break that
contract — Cassandra/Sqlite tests touch real databases, the
broker tests spin up real Kafka/MQTT/Redis containers when
*_LIVE=1, the multi-node tests fork worker threads.

When we land #293 (multi-runtime CI), #296 (testcontainer broker
suites), and #297 (S3 LocalStack), we'll be adding many more
tests that legitimately don't belong in tests/unit/. Without
the split, tests/unit/ becomes a meaningless catch-all.

Scope

  • Move from:
    tests/unit/{cluster,persistence,io,...}/...
    tests/multi-node/...
    
    to:
    tests/unit/         — pure in-process tests, no external services
    tests/integration/  — multi-process, containers, real cloud SDK paths
    
  • File moves only — no test-code edits. Suggested mapping:
    • tests/multi-node/**tests/integration/cluster/
    • tests/unit/cluster/sharding/CassandraRememberEntitiesStore.test.tstests/integration/persistence/
    • tests/unit/persistence/CassandraJournal.test.tstests/integration/persistence/
    • tests/unit/persistence/CassandraTagIndex.test.tstests/integration/persistence/
    • tests/unit/io/broker/*Actor.test.ts (the ones with *_LIVE=1 opt-in containers) → tests/integration/io/
    • tests/unit/coordination/KubernetesLease.test.tstests/integration/coordination/
  • Add separate package.json scripts:
    • bun test tests/unit — fast path, runs in PR CI
    • bun test tests/integration — slow path, runs nightly or
      on-demand
    • bun test — both (current behaviour)
  • Update CI to run them in separate jobs so failures are
    pre-attributed.

Acceptance criteria

  • tests/integration/ contains all tests that touch real
    external services, multi-process workers, or cross-runtime
    I/O.
  • tests/unit/ runs in < 30 s on a developer laptop.
  • bun test still runs both groups by default.
  • No test was removed or skipped during the move — only
    relocated.

Out of scope

  • Renaming individual tests for clarity. This is purely the
    directory split.
  • Restructuring tests/util/ — those are helpers, not tests.

Notes

This issue should land before #296 (broker testcontainers),
#297 (S3 LocalStack), and #298 (K8s providers) — those would
otherwise add 10+ new files into a directory whose semantics are
about to change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions