Skip to content

Conversation

@yuuki
Copy link
Owner

@yuuki yuuki commented Jun 10, 2025

Summary

  • Extract all result printing logic from client.go into a dedicated printer.go module
  • Create Printer struct with configurable io.Writer for better testability and flexibility
  • Add comprehensive unit tests covering all methods and edge cases

Changes

  • New files:

    • printer.go - Contains Printer struct and all printing methods
    • printer_test.go - Comprehensive unit tests for printer functionality
  • Modified files:

    • client.go - Removed printing functions, updated to use new Printer
    • main.go - Updated to use new Printer interface
    • client_test.go, e2e_test.go, jsonlines_test.go - Updated to use new Printer

Benefits

  • Better separation of concerns - Printing logic is now isolated in its own module
  • Improved testability - Printer can be tested in isolation with mock writers
  • Enhanced maintainability - All printing functionality is centralized
  • Greater flexibility - Printer can write to any io.Writer implementation
  • Backwards compatibility - All existing functionality works exactly the same

Test plan

  • All existing tests pass without modification to their behavior
  • Added 13 new comprehensive unit tests for printer functionality
  • Tests cover all public methods and edge cases
  • Tests verify JSON structure, formatting, and error handling
  • Build and linting pass successfully

🤖 Generated with Claude Code

yuuki and others added 2 commits June 10, 2025 15:39
- Extract all result printing logic from client.go into printer.go
- Create Printer struct with configurable io.Writer for better testability
- Move PrintStatHeader, PrintStatLine, PrintReport, and PrintJSONLinesReport methods
- Move JSONLinesResult struct to printer module
- Update all callers to use new Printer interface
- Add comprehensive unit tests in printer_test.go covering all methods and edge cases
- Maintain backwards compatibility with existing functionality
- Improve separation of concerns and code maintainability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Move toMicroseconds and toMicrosecondsf helper functions from client.go to printer.go
- These functions are only used by the printer module for latency calculations
- Add missing newline at end of printer.go file

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@yuuki yuuki merged commit 986c2aa into main Jun 10, 2025
1 check passed
@yuuki yuuki deleted the feature/refactor-printer-module branch June 10, 2025 15:44
@github-actions github-actions bot mentioned this pull request Jun 10, 2025
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.

2 participants