Skip to content

Add Cucumber test for default cooldown#93

Merged
leynos merged 3 commits intomainfrom
codex/add-cucumber-test-for-cooldown_period_seconds-default
Sep 14, 2025
Merged

Add Cucumber test for default cooldown#93
leynos merged 3 commits intomainfrom
codex/add-cucumber-test-for-cooldown_period_seconds-default

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Sep 12, 2025

Summary

  • add Cucumber step to check cooldown_period_seconds
  • cover default cooldown period in config feature

Testing

  • make fmt
  • make lint
  • make test

closes #9


https://chatgpt.com/codex/tasks/task_e_68c3f86217ec8322bcf946454f3b48fe

Summary by Sourcery

Add Cucumber test for default cooldown period in daemon configuration

Tests:

  • Introduce a step definition for a configuration file with no cooldown_period_seconds
  • Add a step definition to assert the cooldown_period_seconds value
  • Add a scenario in the config.feature to validate the default cooldown period of 960 seconds

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Sep 12, 2025

Reviewer's Guide

This PR augments the Cucumber tests to verify the default cooldown_period_seconds by adding new step definitions for missing cooldown settings and corresponding assertions, updating the feature file with a dedicated scenario, and tidying up clippy annotations in config_steps.rs.

File-Level Changes

Change Details Files
Add Cucumber step definitions for default cooldown handling
  • Introduce a Given step for configuration without cooldown_period_seconds
  • Implement then step to assert cooldown_period_seconds value from loaded config
tests/steps/config_steps.rs
Extend feature file with scenario for default cooldown period
  • Add 'uses default cooldown period' scenario in config.feature
  • Define Given, When, Then steps to cover default cooldown behavior
tests/features/config.feature
Clean up clippy expect annotations in step definitions
  • Reposition #[expect(clippy::expect_used)] attributes to suppress lint warnings consistently
tests/steps/config_steps.rs

Assessment against linked issues

Issue Objective Addressed Explanation
#9 Add a test to verify that the default value of cooldown_period_seconds is set when the field is omitted from the config.
#9 Implement a Cucumber step to assert the value of cooldown_period_seconds.
#9 Add a scenario to the Cucumber feature file that loads a config without specifying cooldown_period_seconds and asserts the default value.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 12, 2025

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Summary by CodeRabbit

  • Tests
    • Added a new scenario to verify the default cooldown period is 960 seconds when not specified in the configuration.
    • Introduced supporting test steps to create a configuration without a cooldown value and assert the resulting cooldown.
    • Performed minor ordering clean-ups of test annotations for consistency.
    • No changes to user-facing behaviour or public APIs.

Walkthrough

Add a Cucumber scenario and step definitions to verify the default value of cooldown_period_seconds (960) when omitted from the config. Reorder two test attributes; no production code or public API changes.

Changes

Cohort / File(s) Summary
Feature: Config default cooldown test
tests/features/config.feature
Add scenario that loads a config with token "abc" and no cooldown_period_seconds, then asserts cooldown_period_seconds equals 960.
Steps: Config Cucumber steps
tests/steps/config_steps.rs
Reorder two #[expect(...)] attributes to follow #[given(...)]. Add Given step to create a config without cooldown_period_seconds (delegates to existing helper). Add Then step to assert cooldown_period_seconds equals expected value by inspecting world.result. No changes to core config loader or public signatures.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Runner as Cucumber Runner
  participant Steps as Step Definitions
  participant Loader as Config Loader
  participant World as Test World

  Runner->>Steps: Given a configuration file with token "abc" and no cooldown_period_seconds
  Steps->>Steps: Call helper to write config with token only
  Steps->>Loader: Trigger config load
  Loader-->>World: Set world.result = Ok(Config{ cooldown_period_seconds: 960, ... })

  Runner->>Steps: Then cooldown_period_seconds is 960
  Steps->>World: Take world.result
  Steps->>Steps: Assert cfg.cooldown_period_seconds == 960
  Steps-->>Runner: Return assertion result
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

In tests add a gentle probe,
Omit the field and watch the globe.
Nine‑sixty rises, steadfast, neat,
A small assertion keeps things sweet.
Green checks wink; the build stays globe.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed Confirm that the title concisely and accurately summarises the primary change: adding a Cucumber test to verify the default cooldown_period_seconds when omitted from the configuration. State that the title is specific, succinct and directly reflects the added test and step definitions without extraneous detail. Accept that the title is suitable for a teammate scanning history.
Linked Issues Check ✅ Passed Confirm that the PR fulfils the objectives of issue #9: it adds a feature scenario that loads a config without cooldown_period_seconds and asserts the default value (960 seconds), implements the #[then] step cooldown_period_seconds_is to check the parsed Config value, and reuses existing setup steps as intended. Accept that these code-level testing objectives are met and that no production API changes were required to satisfy the issue.
Out of Scope Changes Check ✅ Passed Inspect the changes and confirm there are no out-of-scope modifications: edits are limited to tests and step definitions with minor clippy attribute reordering, and the summaries indicate no changes to core config loading logic or public API signatures. Accept that the PR is narrowly focused on test coverage for the default cooldown value.
Description Check ✅ Passed Verify that the PR description is relevant and aligns with the changeset: it documents adding a Cucumber step and scenario for the default cooldown_period_seconds, lists test commands, and references closing issue #9. Mark the description as adequate for reviewers and suitable for the commit history.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6264dfd and a15f480.

📒 Files selected for processing (2)
  • tests/features/config.feature (1 hunks)
  • tests/steps/config_steps.rs (4 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 using Arc to 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 unnecessary mut bindings.
Handle errors with the Result type instead of panicking where feasible.
Avoid unsafe code unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not use return in 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.
Prefer expect over allow.
Use rstest fixtures for shared setup.
Replace duplicated tests with #[rstest(...)] parameterised cases.
Prefer mockall for mocks/stubs.
Prefer .expect() over .unwrap().
Use concat!() to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums. Derive std::error::Error (via the thiserror crate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary. Use eyre::Report for 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 to eyre only in the main main() entrypoint or top-level async task.

Files:

  • tests/steps/config_steps.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 return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless 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.
  • Where code is only used by specific features, it must be conditionally compiled or a conditional expectation for unused_code applied.

  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for 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.
  • Environment access (env::set_var and env::remove_var) are always unsafe in Rust 2024 and MUST be marked as such

    • For testing of functionality depending upon environment variables, dependency injection and the mockable crate are the preferred option.
    • If mockable cannot be used, env mutations in tests ...

Files:

  • tests/steps/config_steps.rs
⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Sourcery review
🔇 Additional comments (4)
tests/features/config.feature (1)

35-38: Accept: DEFAULT_COOLDOWN is 960

DEFAULT_COOLDOWN is set to 960 in crates/comenqd/src/config.rs (const DEFAULT_COOLDOWN: u64 = 960) and Config.cooldown_period_seconds uses #[serde(default = "default_cooldown")], so the test expecting 960 matches the implementation.

tests/steps/config_steps.rs (3)

35-36: Keep targeted lint expectations co-located with step attributes.

The scoped #[expect(clippy::expect_used, ...)] is correctly applied for test-only .expect(...) usage. LGTM.


45-46: Align lint expectations for parity with other steps.

The added #[expect(clippy::expect_used, ...)] is appropriate here. LGTM.


127-133: Assert cooldown cleanly from loaded config.

The assertion pattern and error path match the existing steps. LGTM.

Comment thread tests/steps/config_steps.rs
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Sep 13, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 13, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Sep 14, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 14, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@leynos leynos force-pushed the codex/add-cucumber-test-for-cooldown_period_seconds-default branch from 745ed47 to 53670fb Compare September 14, 2025 12:00
@github-actions
Copy link
Copy Markdown

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 14, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a15f480 and 53670fb.

📒 Files selected for processing (2)
  • tests/features/config.feature (1 hunks)
  • tests/steps/config_steps.rs (4 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 return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless 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.
  • Where code is only used by specific features, it must be conditionally compiled or a conditional expectation for unused_code applied.

  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for 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.
  • Environment access (env::set_var and env::remove_var) are always unsafe in Rust 2024 and MUST be marked as such

    • For testing of functionality depending upon environment variables, dependency injection and the mockable crate are the preferred option.
    • If mockable cannot be used, env mutations in tests ...

Files:

  • tests/steps/config_steps.rs
🔍 Remote MCP Ref

Summary of relevant facts for reviewing PR #93

  • Files added/changed in the PR branch:

    • tests/features/config.feature — adds a scenario that loads a config with token "abc" and no cooldown_period_seconds, then asserts cooldown_period_seconds is 960.
    • tests/steps/config_steps.rs — adds a step to set up a config without cooldown (delegates to config_file_with_token) and adds the then-step matching r#"^cooldown_period_seconds is (\d+)$"# which does match world.result.take() { Some(Ok(cfg)) => assert_eq!(cfg.cooldown_period_seconds, expected), other => panic!(...)}. Also reorders two clippy attribute annotations (no semantic change).
  • Scope: The PR modifies only test files (Cucumber feature + step definitions); it does not change production/config-loading code in the PR itself. Reviewers should therefore verify the asserted default (960) against the canonical config implementation (src/config.rs or equivalent) to ensure the test matches the actual default.

Suggested quick review checklist

  • Confirm the config implementation's default for cooldown_period_seconds is 960 (so the new test is correct).
  • Run the test suite locally (make fmt, make lint, make test) to ensure no false failures.
  • Verify the then-step's panic message and pattern matching are sufficient for diagnosability if parsing fails.

Sources used

  • tests/features/config.feature (PR branch).
  • tests/steps/config_steps.rs (PR branch).
  • Repository search/metadata referenced during review.
🔇 Additional comments (4)
tests/steps/config_steps.rs (3)

35-35: Attribute order and scope are correct.

Keep the clippy expectation narrowly scoped under the step attribute.


45-45: Attribute order and scope are correct.

Maintain this placement for consistent lint scoping.


135-141: Then-step for cooldown assertion is correct.

Regex, typing, and result handling match existing patterns.

tests/features/config.feature (1)

35-38: Leave the scenario as-is — the canonical default cooldown is 960.

DEFAULT_COOLDOWN is set to 960 in crates/comenqd/src/config.rs; docs and packaging also reference 960.

Comment thread tests/steps/config_steps.rs
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Sep 14, 2025

@coderabbitai pause

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 14, 2025

✅ Actions performed

Reviews paused.

@leynos leynos force-pushed the codex/add-cucumber-test-for-cooldown_period_seconds-default branch from deb3225 to 94f0be9 Compare September 14, 2025 23:47
@leynos leynos merged commit b415cbb into main Sep 14, 2025
2 of 3 checks passed
@leynos leynos deleted the codex/add-cucumber-test-for-cooldown_period_seconds-default branch September 14, 2025 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test to assert default value of cooldown_period_seconds in config

1 participant