Skip to content

refactor(follow): extract merger logic into a testable method#1353

Merged
pamburus merged 1 commit intomasterfrom
extract-merge-segments
Feb 28, 2026
Merged

refactor(follow): extract merger logic into a testable method#1353
pamburus merged 1 commit intomasterfrom
extract-merge-segments

Conversation

@pamburus
Copy link
Copy Markdown
Owner

Summary

  • Extract the merger thread's inline logic in follow mode into a standalone testable method, mirroring the pattern already used for segment processing
  • Add 6 unit tests covering the merger logic: single line output, timestamp ordering, multi-source interleaving, out-of-order sync indicator, empty channel, and multiple lines per segment
  • No logic changes — pure refactoring

Motivation

The merger logic in follow mode was an inline closure spanning ~60 lines inside a thread spawn call, making it impossible to test without OS-level file watching and threading. Extracting it into a method allows direct unit testing via channels, unblocking test coverage for upcoming changes to this code path.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 28, 2026

Codecov Report

❌ Patch coverage is 96.07843% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.99%. Comparing base (5669f0a) to head (cacd126).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/app.rs 96.07% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1353      +/-   ##
==========================================
+ Coverage   89.83%   89.99%   +0.16%     
==========================================
  Files          72       72              
  Lines       12246    12258      +12     
==========================================
+ Hits        11001    11032      +31     
+ Misses       1245     1226      -19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The merger thread in follow mode contained ~60 lines of inline logic that could not be unit-tested without OS-level file watching and threading. It is now a standalone method callable with channels, enabling direct test coverage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pamburus pamburus force-pushed the extract-merge-segments branch from 1287907 to cacd126 Compare February 28, 2026 15:06
@pamburus pamburus marked this pull request as ready for review February 28, 2026 15:10
@pamburus pamburus merged commit e2587fd into master Feb 28, 2026
13 checks passed
@pamburus pamburus deleted the extract-merge-segments branch February 28, 2026 15:11
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