Repository navigation
fix(tests): date-sensitive gift tests use dynamic dates (v0.5.2) - #89
Merged
Merged
Conversation
3 tests hardcoded 2026-08-18 dates for gift grants; after midnight the
grants were expired at settle/deduct time, failing assertions expecting
'used'. Replace with SQLite dynamic dates: datetime('now') for granted_at
and strftime('%Y-%m-%d 23:59:59', 'now'[,'+1 day'|'-1 day']) for
expires_at. Also make test user created_at dynamic via a ts() helper and
bump version to v0.5.2.
Fixes: billing settle_deducts_gift_first_then_permanent /
settle_expired_gift_not_consumed; gift deduct_gift_first_oldest_expiry /
deduct_overflow_falls_to_permanent / expired_gift_cleaned_lazily.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes 3 time-sensitive tests that fail after midnight: tests hardcoded
2026-08-18dates for gift grants, so once the date rolled over the grants were already pastexpires_atand lazily markedexpiredinstead ofused, breaking assertions.Affected tests (host rant 2026-08-19T10:13:47 — BUG 时间敏感测试):
billing::tests::settle_deducts_gift_first_then_permanentgift::tests::deduct_gift_first_oldest_expirygift::tests::deduct_overflow_falls_to_permanentChanges
'2026-08-18 10:00:00' / '2026-08-18 23:59:59'with SQLite dynamic dates:datetime('now')strftime('%Y-%m-%d 23:59:59', 'now')strftime('%Y-%m-%d 23:59:59', 'now', '+1 day')datetime('now', '-1 day')/strftime('%Y-%m-%d 23:59:59', 'now', '-1 day')settle_expired_gift_not_consumed,expired_gift_cleaned_lazily, test usercreated_at(newts()helper),outside_window_no_gift(-11 days)Tests
cargo test— 102/102 pass (previously 3 failing)cargo clippy --all-targets -- -D warnings— cleancargo fmt --check— clean