Skip to content

Rewrite v3 time-dependent tests with testing/synctest#25

Merged
umputun merged 1 commit intomasterfrom
synctest-deterministic-time
Feb 15, 2026
Merged

Rewrite v3 time-dependent tests with testing/synctest#25
umputun merged 1 commit intomasterfrom
synctest-deterministic-time

Conversation

@paskal
Copy link
Collaborator

@paskal paskal commented Feb 10, 2026

Summary

  • Replace wall-clock sleeps with testing/synctest fake clock in v3 expiry tests
  • Use build tags to keep both variants:
    • cache_expire_test.go (!go1.25): original time.Sleep-based tests for Go < 1.25
    • cache_expire_synctest_test.go (go1.25): deterministic synctest-based tests for Go 1.25+
  • Bump v3/go.mod from go 1.20 to go 1.23 (required for sync timer channels used by synctest)
  • Bump v3 CI to Go 1.25 (where testing/synctest is stable)
  • v1 and v2 remain unchanged on go 1.20

Tests rewritten (v3 only)

  • TestCacheWithDeleteExpired
  • TestCacheExpired
  • TestCache_GetExpiration

Addresses #24

@coveralls
Copy link

coveralls commented Feb 10, 2026

Pull Request Test Coverage Report for Build 22014540053

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 19903535070: 0.0%
Covered Lines: 226
Relevant Lines: 226

💛 - Coveralls

@paskal paskal marked this pull request as ready for review February 11, 2026 00:06
@paskal paskal requested a review from umputun as a code owner February 11, 2026 00:06
@umputun
Copy link
Member

umputun commented Feb 11, 2026

the test rewrite looks clean, but bumping go.mod from 1.20 to 1.25 in all three modules (v1, v2, v3) seems like an oversight - that's a major minimum version jump just for test changes. v1 and v2 especially shouldn't need this since they're legacy and consumers may still be on older Go versions.

since synctest is only used in test files, could you keep the go.mod versions unchanged and use a build tag instead? that way the library stays compatible with older Go while tests use synctest on 1.24+.

@paskal paskal marked this pull request as draft February 14, 2026 08:31
@paskal paskal force-pushed the synctest-deterministic-time branch from eddd0f5 to e3a0578 Compare February 14, 2026 08:47
@paskal paskal changed the title Rewrite time-dependent tests with testing/synctest Rewrite v3 time-dependent tests with testing/synctest Feb 14, 2026
@paskal paskal marked this pull request as ready for review February 14, 2026 08:48
Use build tags to split expiry tests into two variants:
- cache_expire_test.go (!go1.25): original time.Sleep-based tests
- cache_expire_synctest_test.go (go1.25): deterministic synctest-based tests

Bump v3/go.mod to go 1.23 (required for sync timer channels)
and CI to Go 1.25 (where synctest is stable). v1 and v2 remain
unchanged on go 1.20.
@paskal paskal force-pushed the synctest-deterministic-time branch from e3a0578 to d93d0b8 Compare February 14, 2026 08:51
@go-pkgz go-pkgz deleted a comment from coveralls Feb 14, 2026
@go-pkgz go-pkgz deleted a comment from coveralls Feb 14, 2026
Copy link
Member

@umputun umputun left a comment

Choose a reason for hiding this comment

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

lgtm, thx. clean split with build tags, addresses the feedback.

@umputun umputun merged commit e8a0aef into master Feb 15, 2026
5 checks passed
@umputun umputun deleted the synctest-deterministic-time branch February 15, 2026 01:49
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.

3 participants