refactor: provide mock builder for test repo stubs #15
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Tests in
tests/integration.rsandtests/activities.rsmust implement all methods of every repository trait (19 for FollowRepository, 7 for ActorRepository, etc.) even when testing a single scenario. Most stubs returnOk(())orOk(vec![]).Adding a new method to any trait breaks all test code. Test intent is buried under boilerplate — it's hard to see what a test actually exercises.
Proposal
Provide a configurable mock builder behind
#[cfg(test)]or atest-supportfeature:Unregistered methods return sensible defaults (
Ok(())for writes,Ok(None)/Ok(vec![])for reads). Optionally track call counts for assertions.Alternatively, use a
#[derive(DefaultMock)]proc macro or a hand-writtenMemRepowith configurable overrides.Files
src/testing.rsorsrc/test_support/mod.rssrc/tests/integration.rs(consumer, simplify)src/tests/activities.rs(consumer, simplify)Trade-offs
Dependency
Best done after #12 (repository trait refactor) since the trait shape determines mock ergonomics.