Conversation
Reviewer's GuideThis PR introduces a new test-utils crate to house shared test helpers, updates workspace and crate dependencies to reference it, and refactors daemon tests to import utilities from the new crate. Class diagram for test-utils crate and test helper usageclassDiagram
class test_utils {
+octocrab_for()
+temp_config()
}
class daemon_tests {
+uses octocrab_for()
+uses temp_config()
+uses wait_for_file() from test_support
}
daemon_tests ..> test_utils : uses
daemon_tests ..> test_support : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
WalkthroughExpand the Cargo workspace to include a new Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Test Code
participant TestUtils as test-utils
participant MockServer as wiremock::MockServer
participant Octocrab as Octocrab
Test->>TestUtils: temp_config(tmp)
TestUtils->>Test: returns Config
Test->>MockServer: start()
MockServer-->>Test: MockServer instance
Test->>TestUtils: octocrab_for(MockServer)
TestUtils->>Octocrab: build client with MockServer URI
Octocrab-->>TestUtils: Octocrab instance
TestUtils-->>Test: Arc<Octocrab>
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes - here's some feedback:
- Consider consolidating test-support and test-utils crates or clarifying their distinct roles to avoid duplication and confusion in test helper usage.
- Add simple tests inside the test-utils crate to verify that temp_config and octocrab_for produce the expected configurations and clients.
- Pull wiremock into the workspace dependencies instead of pinning it only in test-utils to keep dependency versions consistent across crates.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider consolidating test-support and test-utils crates or clarifying their distinct roles to avoid duplication and confusion in test helper usage.
- Add simple tests inside the test-utils crate to verify that temp_config and octocrab_for produce the expected configurations and clients.
- Pull wiremock into the workspace dependencies instead of pinning it only in test-utils to keep dependency versions consistent across crates.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
Cargo.toml(1 hunks)crates/comenqd/Cargo.toml(1 hunks)crates/comenqd/src/daemon.rs(1 hunks)crates/test-utils/Cargo.toml(1 hunks)crates/test-utils/src/lib.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
Cargo.toml
📄 CodeRabbit Inference Engine (AGENTS.md)
Cargo.toml: Use explicit version ranges inCargo.tomland keep dependencies up-to-date.
Mandate caret requirements for all dependencies: All crate versions specified inCargo.tomlmust use SemVer-compatible caret requirements (e.g.,some-crate = "1.2.3").
Prohibit unstable version specifiers: The use of wildcard (*) or open-ended inequality (>=) version requirements is strictly forbidden as they introduce unacceptable risk and unpredictability. Tilde requirements (~) should only be used where a dependency must be locked to patch-level updates for a specific, documented reason.
Files:
Cargo.toml
**/*.rs
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.rs: Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Useconcat!()to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums. Derivestd::error::Error(via thethiserrorcrate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary. Useeyre::Reportfor human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library. Convert to domain enums at API boundaries, and toeyreonly in the mainmain()entrypoint or top-level async task.
Files:
crates/comenqd/src/daemon.rscrates/test-utils/src/lib.rs
⚙️ CodeRabbit Configuration File
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Files:
crates/comenqd/src/daemon.rscrates/test-utils/src/lib.rs
🔇 Additional comments (5)
Cargo.toml (1)
35-35: LGTM!The workspace member addition is correctly structured and follows the existing pattern.
crates/comenqd/Cargo.toml (1)
27-27: LGTM!The development dependency addition is correctly structured using the appropriate relative path.
crates/comenqd/src/daemon.rs (1)
243-244: LGTM!The import refactoring correctly utilises the new shared test utilities, improving code organisation and reusability.
crates/test-utils/src/lib.rs (2)
23-34: Add rustdoc documentation for the public API.The coding guidelines require documenting public APIs using Rustdoc comments (
///).+/// Construct an [`Octocrab`] client for a [`MockServer`]. +/// +/// Creates an authenticated Octocrab client configured to communicate +/// with the provided mock server for testing GitHub API interactions. +/// +/// # Parameters +/// - `server`: mock server to configure the client for +/// +/// # Returns +/// An [`Arc<Octocrab>`] instance configured for the mock server #[expect(clippy::expect_used, reason = "simplify test helper setup")] pub fn octocrab_for(server: &MockServer) -> Arc<Octocrab> {Likely an incorrect or invalid review comment.
13-21: Add rustdoc documentation for the public API.The coding guidelines require documenting public APIs using Rustdoc comments (
///) so documentation can be generated withcargo doc.+/// Build a [`Config`] using paths inside `tmp`. +/// +/// Creates a test configuration with default values suitable for testing, +/// using the provided temporary directory for socket and queue paths. +/// +/// # Parameters +/// - `tmp`: temporary directory to use for file paths +/// +/// # Returns +/// A [`Config`] instance configured for testing pub fn temp_config(tmp: &TempDir) -> Config {Likely an incorrect or invalid review comment.
Summary
test-utilscrate to share test helperstest-utilsincomenqddev-dependenciesTesting
make lintmake testhttps://chatgpt.com/codex/tasks/task_e_688d12f4271483229cc2cd3a0ff2e959
Summary by Sourcery
Introduce a new test-utils crate for sharing common test helpers and update comendqd tests and configurations to use it
New Features:
Enhancements:
Build:
Tests: