Skip to content

Conversation

@isSerge
Copy link
Owner

@isSerge isSerge commented Jul 28, 2025

Closes #81

  • Create TestHarness utility struct with helper methods
  • Move unit tests for handlers to dedicated command and callback modules

@isSerge isSerge requested a review from Copilot July 28, 2025 23:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Refactors unit tests for bot handlers to use a TestHarness utility and moves tests closer to the code they test. The PR eliminates a large central test file in favor of dedicated test modules within each handler module.

  • Creates a TestHarness utility struct with helper methods to simplify test setup
  • Moves command handler tests from centralized location to dedicated add.rs module
  • Moves callback handler tests to their respective modules (view_repo.rs, view_labels.rs, remove.rs, list.rs)

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/bot_handler/tests.rs Removes entire centralized test file (1008 lines deleted)
src/bot_handler/test_helpers.rs Adds new test utility module with TestHarness and helper functions
src/bot_handler/mod.rs Updates module imports and adds Display trait for Command enum
src/bot_handler/commands/add.rs Adds comprehensive test module for add command functionality
src/bot_handler/callbacks/view_repo.rs Adds test module for repository detail view callbacks
src/bot_handler/callbacks/view_labels.rs Adds test module for label view and toggle callbacks
src/bot_handler/callbacks/remove.rs Adds test module for repository removal callbacks
src/bot_handler/callbacks/list.rs Adds test module for repository list callbacks

Comment on lines +324 to +325
let limit_error_msg = "You have reached the maximum limit of 10
repositories.";
Copy link

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

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

The multi-line string literal should be properly formatted. Consider using a single line or proper indentation to avoid confusion about the actual error message content.

Suggested change
let limit_error_msg = "You have reached the maximum limit of 10
repositories.";
let limit_error_msg = "You have reached the maximum limit of 10 repositories.";

Copilot uses AI. Check for mistakes.
Comment on lines +434 to +435
"{url_new} {url_tracked} {url_notfound} {url_invalid} {url_gh_error}
{url_add_error}"
Copy link

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

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

The multi-line string literal should be properly formatted. Consider using a single line or proper indentation to maintain consistency with the test data structure.

Suggested change
"{url_new} {url_tracked} {url_notfound} {url_invalid} {url_gh_error}
{url_add_error}"
"{url_new}\n\
{url_tracked}\n\
{url_notfound}\n\
{url_invalid}\n\
{url_gh_error}\n\
{url_add_error}"

Copilot uses AI. Check for mistakes.
isSerge and others added 3 commits July 29, 2025 06:45
@isSerge isSerge merged commit c44fb37 into main Jul 28, 2025
4 checks passed
@isSerge isSerge deleted the simplify-handlers-test-setup branch July 28, 2025 23:51
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.

Simplify unit tests setup for command and callback handlers

2 participants