Mikhail Kilin
|
e690acfb09
|
test: complete Phase 4 testing - utils tests and performance benchmarks
Added 9 new unit tests for utils/formatting.rs functions:
- format_date: 4 tests (today, yesterday, old, epoch)
- format_was_online: 5 tests (just now, minutes/hours/days ago, very old)
Created 3 performance benchmark files using criterion:
- benches/group_messages.rs - message grouping benchmarks
- benches/formatting.rs - timestamp/date formatting benchmarks
- benches/format_markdown.rs - markdown parsing benchmarks
Updated documentation:
- CONTEXT.md: added Phase 4.1 (Utils) and 4.2 (Benchmarks) completion
- Total coverage: 188 tests + 8 benchmarks = 196 tests (100%)
All 565 tests passing with 100% success rate.
|
2026-02-01 23:04:43 +03:00 |
|
Mikhail Kilin
|
c6beea5608
|
refactor: create timeout/retry utilities to reduce code duplication (P1.1)
Created new utility modules to eliminate repeated timeout/retry patterns:
- src/utils/retry.rs: with_timeout() and with_timeout_msg() helpers
- src/utils/formatting.rs: timestamp formatting utilities (from utils.rs)
- src/utils/tdlib.rs: TDLib log configuration utilities (from utils.rs)
Refactored src/input/main_input.rs:
- Replaced 18+ instances of timeout(Duration, op).await pattern
- Simplified error handling from nested Ok(Ok(...))/Ok(Err(...))/Err(...)
to cleaner Ok(...)/Err(...) with custom timeout messages
- Added type annotations for compiler type inference
Benefits:
- Reduced code duplication from ~20 instances to 2 utility functions
- Cleaner, more readable error handling
- Easier to maintain timeout logic in one place
- All 59 tests passing
Progress: REFACTORING_OPPORTUNITIES.md #1 (Дублирование кода) - Частично выполнено
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
2026-02-01 19:56:33 +03:00 |
|