Skip to content

Test code coverage increased.#330

Open
cinar wants to merge 1 commit intomasterfrom
coverage-improvement
Open

Test code coverage increased.#330
cinar wants to merge 1 commit intomasterfrom
coverage-improvement

Conversation

@cinar
Copy link
Owner

@cinar cinar commented Feb 25, 2026

Describe Request

Test code coverage increased.

Change Type

Code maintenance.

Summary by CodeRabbit

  • New Features

    • Added an interactive HTML dashboard for percent B and Money Flow Index strategy visualization.
    • Introduced customizable constructor for Money Flow Index indicator with configurable periods.
  • Tests

    • Expanded test coverage across SQL repository, backtest, helper utilities, and strategy modules.
    • Added error handling and edge-case validation tests for improved robustness.
  • Bug Fixes

    • Improved error detection logic in channel comparison utilities for better mismatch reporting.
    • Enhanced stream processing with additional buffering for improved performance.
  • Documentation

    • Updated sequence documentation for clarity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

This PR introduces comprehensive unit tests across asset, backtest, helper, strategy, trend, and volume packages. Additionally, it includes minor production code changes: new constructors in volume/mfi.go, control flow refactoring in helper/check.go, buffering additions to strategy streams, lagging line adjustments in momentum/ichimoku_cloud.go, and a new HTML dashboard for the PercentBandMFI strategy.

Changes

Cohort / File(s) Summary
Asset Tests
asset/sql_repository_test.go
New comprehensive test file with mock SQL driver and dialect implementations, testing SQL repository operations including Assets, Get, LastDate, Append, and Drop methods with error path coverage.
Backtest Tests
backtest/backtest_test.go, backtest/html_report_test.go
New test files introducing error handling validation (Begin errors, AssetBegin errors), no-strategies scenario, and HTML report generation tests including error cases and disabled strategy reports.
Helper Core Logic
helper/check.go
Refactored channel pair comparison logic replacing nested loops with single outer loop using allDone flag; now returns error immediately on actualOk/expectedOk mismatch instead of deferring comparison.
Helper Tests
helper/check_test.go, helper/database_test.go, helper/operate4_test.go, helper/percent_rank_test.go, helper/remove_test.go, helper/seq_test.go
New test files providing comprehensive coverage for multi-pair equality checks, database closure logic, Operate4 function, percent-rank calculations, file removal utilities, and sequence generation with edge cases.
Helper Documentation
helper/seq.go
Updated documentation comment to clarify Seq sequence includes start value but excludes end value; no behavioral changes.
Volume Package
volume/mfi.go
Introduced NewMfiWithPeriod constructor enabling custom period initialization; updated NewMfi to delegate to new constructor.
Momentum Indicator
momentum/ichimoku_cloud.go
Added SkipLast transformation to laggingLine processing to align lagging span by dropping trailing elements.
Strategy/Volume
strategy/volume/percent_b_and_mfi_strategy.go, strategy/volume/percent_b_and_mfi_strategy.html, strategy/volume/percent_b_and_mfi_strategy_test.go, strategy/volume/volume_test.go
Added buffering to MFI, percent B, and outcome streams; introduced new HTML dashboard visualization; refactored tests to use in-memory synthetic snapshots instead of CSV files; added AllStrategies count validation test.
Trend Indicators
trend/slow_stochastic_test.go
New test file validating SlowStochastic indicator behavior with default and custom parameters, idle period computation, and output range validation using generic type instantiation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Tests spring forth like carrots in spring,
Helper functions dance and sing!
SlowStochastic, MFI align,
With buffers and mocks, all design so fine—
Coverage grows, the code shines bright! 🌟

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch coverage-improvement

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant