Does macro-inc/macro Have Unit Tests and Where Are They Located: Complete Guide
Yes, the macro-inc/macro repository maintains an extensive automated test suite with unit tests organized in tests/ directories within each Rust crate and end-to-end scenarios centralized in crates/integration_tests.
The macro-inc/macro monorepo follows Rust workspace conventions where every component keeps its validation logic separate from production code. Understanding the exact file locations and test architecture enables efficient contribution and debugging across the task deduplication, authentication, and database client systems.
Unit Test Architecture in the Macro Monorepo
Each crate in the workspace maintains a dedicated tests/ directory at the crate root, following Rust's standard layout for integration-style test binaries. Tests placed in these directories compile as separate executables that import the crate’s public API, ensuring validation occurs against the same interface exposed to downstream consumers.
The repository employs two primary testing patterns:
- Unit-style tests: Using
#[cfg(test)]modules for internal logic or standalone files intests/for focused component validation - Integration binaries: Separate test executables in
tests/directories that verify crate boundaries and cross-module interactions
A dedicated crates/integration_tests workspace supplements these with end-to-end scenarios spanning multiple services.
Where to Find Unit Tests by Component
Task Deduplication Service
The task deduplication logic resides in crates/task_dedup/ with comprehensive evaluation suites located in crates/task_dedup/tests/eval/. The file crates/task_dedup/tests/eval/main.rs contains tests that verify deduplication behavior under various concurrency and load conditions.
Database Client (macro_db_client)
Database interaction and normalization logic is tested in crates/macro_db_client/tests/. The file crates/macro_db_client/tests/normalize_macro_bot_mention_ids.rs validates Slack mention ID parsing and bot suffix stripping.
Authentication Service (macro_auth)
Security-critical authentication flows are tested in crates/macro_auth/tests/, with internal_api_key.rs verifying internal API key validation and permission enforcement.
Client Cache Libraries
The client-side caching system spans multiple crates under crates/client/cache-*/, each maintaining tests/ directories. For instance, crates/client/cache-core/tests/engine.rs tests the core caching engine supporting WebAssembly, SQLite, and IndexedDB implementations.
Prompt Composition System
LLM prompt construction and template rendering is validated in crates/prompt/tests/, particularly in compose.rs, ensuring consistent prompt generation across different model contexts.
End-to-End Integration Suite
Cross-service integration tests live in crates/integration_tests/local_e2e/tests/. The file channel_websocket.rs validates real-time WebSocket communication channels across the entire service stack.
Running the macro-inc/macro Test Suite
Execute the complete test suite from the repository root:
cargo test
This command discovers and runs all tests across the workspace, including unit tests, integration binaries, and documentation tests.
To focus on a specific component without compiling the entire monorepo, use the package flag:
cargo test -p macro_db_client
cargo test -p macro_auth
cargo test -p task_dedup
This targeted approach reduces compilation time during iterative development on individual crates.
Example Unit Test Implementation
The following test from crates/macro_db_client/tests/normalize_macro_bot_mention_ids.rs demonstrates the repository's async testing patterns using Tokio:
#[tokio::test]
async fn test_normalize_macro_bot_mention_ids() {
// Arrange – a raw mention string that contains a macro‑bot ID
let raw = "<@U12345|macro-bot>";
// Act – run the normalisation helper
let normalized = normalize_macro_bot_mention_ids(&raw).await.unwrap();
// Assert – the result should be the plain user ID without the bot suffix
assert_eq!(normalized, "U12345");
}
This example follows the Arrange-Act-Assert pattern, utilizing tokio::test for async runtime support while verifying that normalize_macro_bot_mention_ids correctly processes Slack mention strings.
Summary
- Test Location: Every crate stores tests in a dedicated
tests/directory at the crate root, keeping validation code separate fromsrc/production files - Pattern: Tests compile as distinct binaries that consume public APIs, with
#[cfg(test)]available for inline unit tests - Integration Testing: End-to-end scenarios reside in
crates/integration_tests/local_e2e/tests/for multi-service validation - Execution:
cargo testruns the full suite;cargo test -p <crate>isolates specific components - Key Files: Critical suites include
crates/task_dedup/tests/eval/main.rs,crates/macro_db_client/tests/normalize_macro_bot_mention_ids.rs,crates/macro_auth/tests/internal_api_key.rs, andcrates/client/cache-core/tests/engine.rs
Frequently Asked Questions
How do I run tests for a specific crate in macro-inc/macro?
Use Cargo's package selector: cargo test -p <crate_name>. For example, cargo test -p macro_db_client compiles and executes only the database client's test suite, significantly reducing build times during focused development iterations.
What testing framework does macro-inc/macro use?
The repository uses Rust's built-in test framework with #[test] for synchronous code and #[tokio::test] for async functions. The standard library's assertion macros are supplemented by Tokio's async runtime for testing non-blocking database and network operations.
Are there integration tests in addition to unit tests?
Yes, the repository maintains both unit tests for internal logic and integration tests in tests/ directories that validate crate boundaries. Additionally, the crates/integration_tests workspace contains end-to-end tests exercising multiple services together.
Where are the end-to-end tests located?
End-to-end tests spanning the full service stack are located in crates/integration_tests/local_e2e/tests/, with files like channel_websocket.rs testing real-time communication flows across integrated components.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →