All tests run offline — no network access or model downloads are needed.
cargo test # all tests
cargo test --lib # library tests only
cargo test --test <name> # a specific integration test
cargo test -- --nocapture # show println! outputModule-level #[cfg(test)] mod tests blocks. These test individual functions and types in isolation. The majority of tests are here.
Files in tests/ test the CLI and MCP server end-to-end by running the binary as a subprocess. Subprocess tests spawn the actual cogz binary, send JSON-RPC over stdio, and verify responses. This catches serialization, protocol, and integration bugs that in-process tests miss.
Tests use MockEmbeddingModel and MockNliModel (in src/embed/model.rs) instead of real ONNX models. Mocks return deterministic embeddings and NLI labels without loading the ONNX Runtime.
This means:
- Tests run in milliseconds, not seconds.
- No model downloads or disk space needed.
- No ONNX Runtime dependency for testing.
- Embedding behavior is deterministic and reproducible.
Tests create temporary directories with tempfile::tempdir() and build minimal .cogz/ structures in them. No shared state between tests — each test gets its own isolated directory and database.
For tests that need a populated database, each test file defines its own helpers that insert entities, edges, and embeddings directly — see tests/test_consolidation.rs for the reference pattern.
When adding a feature:
- Unit test the core logic. Test the function in isolation with mock dependencies.
- Integration test the CLI path. If the feature is exposed via a CLI command, add a subprocess test.
- Integration test the MCP path. If the feature is exposed via an MCP tool, add a subprocess MCP test.
- Test edge cases. Empty inputs, missing files, corrupt data, concurrent access (single-threaded but reentrant code paths).
- Test degradation. If the feature uses models, test the FTS-only fallback.
There is no automated coverage tool configured. Coverage is assessed by:
- Every public function having at least one test.
- Every CLI command having at least one subprocess test.
- Every MCP tool having at least one subprocess test.
- Every error path having a test that triggers it.
GitHub Actions runs on every push and PR to master (ci.yml):
cargo fmt --checkcargo clippy -- -D warningscargo build --releasecargo test
The check job runs on three platforms (Ubuntu x86_64, macOS arm64, Windows x86_64), and ci.yml also builds the Docker image and verifies an MCP handshake inside it, and runs cargo audit. All jobs must pass before merge.
- Building — build commands and release process
- Conventions — code patterns