Skip to content

refactor: add RestoreAt and rename From to At#50

Merged
k1LoW merged 1 commit intomainfrom
limit-default-time
Jan 5, 2026
Merged

refactor: add RestoreAt and rename From to At#50
k1LoW merged 1 commit intomainfrom
limit-default-time

Conversation

@k1LoW
Copy link
Copy Markdown
Owner

@k1LoW k1LoW commented Jan 5, 2026

This pull request refactors the time-based position logic in the pos package to improve clarity and testability. The main changes include renaming the From function to At, introducing a new RestoreAt function for restoring positions with a specific reference time, and updating the tests to use these new interfaces and more predictable, fixed times.

API improvements and refactoring:

  • Renamed From to At in pos.go to clarify that it creates a position at a specific point in time. [1] [2]
  • Added RestoreAt to allow restoring a Pos from serialized data using an explicit reference time, and refactored the original Restore to delegate to this new function.

Testing improvements:

  • Updated pos_test.go to use a fixed now time for deterministic testing, and replaced all test invocations of From/Restore with At/RestoreAt. This ensures tests are not dependent on the system clock and improves reliability. [1] [2] [3] [4]

@k1LoW k1LoW self-assigned this Jan 5, 2026
@k1LoW k1LoW added enhancement New feature or request tagpr:minor labels Jan 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 5, 2026

Code Metrics Report

main (7f65bc5) #50 (73c3ce8) +/-
Coverage 5.8% 6.1% +0.2%
Code to Test Ratio 1:0.1 1:0.1 -0.1
Test Execution Time 11s 10s -1s
Details
  |                     | main (7f65bc5) | #50 (73c3ce8) |  +/-  |
  |---------------------|----------------|---------------|-------|
+ | Coverage            |           5.8% |          6.1% | +0.2% |
  |   Files             |             10 |            10 |     0 |
  |   Lines             |            407 |           408 |    +1 |
+ |   Covered           |             24 |            25 |    +1 |
- | Code to Test Ratio  |          1:0.1 |         1:0.1 |  -0.1 |
  |   Code              |            942 |           945 |    +3 |
- |   Test              |            108 |           104 |    -4 |
+ | Test Execution Time |            11s |           10s |   -1s |

Code coverage of files in pull request scope (19.6% → 20.3%)

Files Coverage +/- Status
cmd/stream.go 0.0% 0.0% modified
pos/pos.go 31.6% +0.8% modified

Reported by octocov

@k1LoW k1LoW merged commit 95c645f into main Jan 5, 2026
2 checks passed
@k1LoW k1LoW deleted the limit-default-time branch January 5, 2026 08:07
@github-actions github-actions Bot mentioned this pull request Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tagpr:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant