Conversation
Reviewer's GuideExtract common test setup logic into a new test_helpers module and refactor existing unit and behavioral tests to use these helpers for Config and Octocrab initialization, removing redundant code. Class diagram for new test_helpers module and usageclassDiagram
class test_helpers {
+temp_config(tempdir) Config
+octocrab_for(server) Octocrab
}
class Config {
github_token: String
socket_path: PathBuf
queue_path: PathBuf
cooldown_period_seconds: u64
}
class Octocrab
class MockServer
test_helpers ..> Config : returns
test_helpers ..> Octocrab : returns
test_helpers ..> MockServer : uses
Class diagram for refactored daemon tests using test_helpersclassDiagram
class DaemonTests {
+setup_run_worker(status: u16) (MockServer, Arc<Config>, Receiver, Arc<Octocrab>)
+run_creates_queue_directory()
+run_listener_accepts_connections()
}
class test_helpers {
+temp_config(tempdir) Config
+octocrab_for(server) Octocrab
}
DaemonTests ..> test_helpers : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
WalkthroughRefactor test setup across multiple files to use shared helper utilities for constructing configuration objects and Octocrab clients. Introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Test Function
participant Helpers as test_helpers
participant Config as Config
participant Octocrab as Octocrab
participant MockServer as MockServer
Test->>Helpers: temp_config(tmp_dir)
Helpers->>Config: Construct Config with tmp_dir
Helpers-->>Test: Return Config
Test->>Helpers: octocrab_for(mock_server)
Helpers->>Octocrab: Build Octocrab with mock_server base_uri
Helpers-->>Test: Return Octocrab
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🧰 Additional context used📓 Path-based instructions (1)**/*.rs📄 CodeRabbit Inference Engine (AGENTS.md)
Files:
⚙️ CodeRabbit Configuration File
Files:
🧬 Code Graph Analysis (2)tests/steps/listener_steps.rs (1)
crates/comenqd/src/daemon.rs (1)
🔇 Additional comments (7)
✨ 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 (
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Stale |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🔭 Outside diff range comments (1)
tests/steps/worker_steps.rs (1)
1-5: Replace #[allow] with narrowly scoped #[expect].The coding guidelines forbid
#[allow]and require narrowly scoped#[expect(lint, reason = "...")]instead. Replace this file-wide suppression with targeted expectations where needed.-#![allow( - clippy::expect_used, - clippy::unwrap_used, - reason = "simplify test output" -)]Then add narrowly scoped expectations where
.expect()and.unwrap()are actually used.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (6)
crates/comenqd/src/daemon.rs(5 hunks)tests/cucumber.rs(1 hunks)tests/steps/listener_steps.rs(2 hunks)tests/steps/worker_steps.rs(3 hunks)tests/util/mod.rs(1 hunks)tests/util/test_helpers.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.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:
tests/steps/listener_steps.rstests/cucumber.rscrates/comenqd/src/daemon.rstests/steps/worker_steps.rstests/util/mod.rstests/util/test_helpers.rs
🧬 Code Graph Analysis (3)
tests/steps/listener_steps.rs (1)
tests/util/test_helpers.rs (1)
temp_config(27-34)
crates/comenqd/src/daemon.rs (1)
tests/util/test_helpers.rs (2)
octocrab_for(50-59)temp_config(27-34)
tests/steps/worker_steps.rs (1)
tests/util/test_helpers.rs (2)
octocrab_for(50-59)temp_config(27-34)
🔇 Additional comments (15)
tests/util/mod.rs (1)
1-4: LGTM! Well-structured module declaration.The module follows coding guidelines with proper documentation and clear organisation of test utilities.
tests/cucumber.rs (1)
2-2: LGTM! Clean integration of test utilities.The module import properly exposes the new test helper utilities to the cucumber test suite.
tests/steps/listener_steps.rs (2)
15-15: LGTM! Proper import of test helpers.The import correctly brings in the shared test utilities.
40-40: LGTM! Clean refactoring to use shared helper.The replacement of manual
Configconstruction withtemp_config(&dir)reduces duplication whilst maintaining identical test behaviour.tests/steps/worker_steps.rs (3)
10-10: LGTM! Proper import of test helpers.The import correctly brings in both shared test utility functions.
39-41: LGTM! Clean refactoring with config modification.The use of
temp_config(&dir)followed by modification ofcooldown_period_secondsmaintains the original test behaviour whilst leveraging the shared helper.
83-83: LGTM! Clean replacement of manual Octocrab construction.The
octocrab_for(server)call properly replaces manual client construction whilst maintaining identical functionality.crates/comenqd/src/daemon.rs (5)
171-171: LGTM! Proper import of test helpers.The import correctly brings in the shared test utility functions.
181-183: LGTM! Clean refactoring in setup helper.The use of
temp_config(&dir)followed by modification maintains the original behaviour whilst leveraging the shared helper.
203-203: LGTM! Clean replacement of manual Octocrab construction.The
octocrab_for(&server)call properly replaces manual client construction in the setup helper.
221-221: LGTM! Consistent use of shared helper.The
temp_config(&dir)call maintains test behaviour whilst using the centralised helper.
284-284: LGTM! Consistent refactoring pattern.The use of
temp_config(&dir)wrapped inArc::new()maintains the original test structure whilst leveraging the shared helper.tests/util/test_helpers.rs (3)
1-4: LGTM on module documentation.The module documentation follows the required
//!format and clearly explains the module's purpose and utility.
27-34: LGTM ontemp_configimplementation.The function follows single responsibility principle, has low complexity, and provides a clean interface for creating test configurations.
50-59: LGTM onoctocrab_forimplementation.The function correctly creates an
Arc<Octocrab>configured for the mock server. The use of.expect()is appropriate for test helpers where panicking on failure is acceptable behaviour.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
crates/comenqd/src/daemon.rs (1)
167-172: Stop relying oninclude!inside the test moduleThe same warning was already issued on a previous revision.
include!pulls raw tokens from an external file, bypassing module hygiene and compiler visibility checks, and breaks IDE navigation. Extract the helpers into a normal crate‐localmod util;(or a dedicatedtest_utilscrate) and import them properly.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
crates/comenqd/src/daemon.rs(5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.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.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.rs
🧬 Code Graph Analysis (1)
crates/comenqd/src/daemon.rs (1)
tests/util/test_helpers.rs (2)
octocrab_for(50-59)temp_config(26-33)
Summary
tests::util::test_helperswith helpers for test config and OctocrabTesting
make fmtmake lintmake testhttps://chatgpt.com/codex/tasks/task_e_6888f8080b8c8322a0de3157b874d0d8
Summary by Sourcery
Introduce reusable test helper utilities and refactor existing tests to leverage them for consistent configuration and Octocrab setup.
New Features:
Enhancements:
Documentation:
Tests: