Skip to content

Conversation

@rm-hull
Copy link
Owner

@rm-hull rm-hull commented Oct 31, 2025

Refactor the core application logic to utilize interfaces for Git and UI operations, allowing dependencies to be injected.

This enables comprehensive unit testing of the application flow and state transitions, addressing the lack of existing tests.

  • Introduces app.Git and app.UI interfaces.
  • Adds github.com/stretchr/testify for assertion helpers.
  • Includes unit tests for app, config, and llm_provider.

Refactor the core application logic to utilize interfaces for
Git and UI operations, allowing dependencies to be injected.

This enables comprehensive unit testing of the application flow
and state transitions, addressing the lack of existing tests.

*   Introduces `app.Git` and `app.UI` interfaces.
*   Adds `github.com/stretchr/testify` for assertion helpers.
*   Includes unit tests for `app`, `config`, and `llm_provider`.
@gemini-code-assist
Copy link

Summary of Changes

Hello @rm-hull, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant architectural improvement by implementing dependency injection within the core application. By abstracting external dependencies like Git operations and UI interactions behind interfaces, the application becomes much easier to test and maintain. This refactoring lays the groundwork for robust unit testing, addressing a critical area for improving code quality and preventing regressions.

Highlights

  • Dependency Injection: The core application logic has been refactored to use dependency injection, utilizing interfaces for Git and UI operations. This significantly improves the modularity and testability of the application.
  • New Interfaces: Introduced app.Git and app.UI interfaces to abstract away concrete implementations of Git commands and user interface interactions, respectively.
  • Unit Testing Framework: The github.com/stretchr/testify assertion library has been added to the project, providing a robust set of tools for writing clear and concise unit tests.
  • Comprehensive Unit Tests: New unit tests have been added for the app, config, and llm_provider packages, covering various scenarios and ensuring the reliability of the refactored components.
  • TODO List Update: The TODO.md file has been updated to reflect that the tasks related to adding unit tests for the core application logic and using a testing framework have been completed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

github-actions bot commented Oct 31, 2025

TestsPassed ✅SkippedFailed
JUnit Test Report16 ran16 passed0 skipped0 failed
TestResult
JUnit Test Report
com/rm-hull/git-commit-summary/internal/app.TestNewApp✅ passed
com/rm-hull/git-commit-summary/internal/app.TestAppRun/DiffError✅ passed
com/rm-hull/git-commit-summary/internal/app.TestAppRun/NoStagedChanges✅ passed
com/rm-hull/git-commit-summary/internal/app.TestAppRun/LLMCallError✅ passed
com/rm-hull/git-commit-summary/internal/app.TestAppRun/TextAreaError✅ passed
com/rm-hull/git-commit-summary/internal/app.TestAppRun/UserAborted✅ passed
com/rm-hull/git-commit-summary/internal/app.TestAppRun/CommitError✅ passed
com/rm-hull/git-commit-summary/internal/app.TestAppRun/Success✅ passed
com/rm-hull/git-commit-summary/internal/app.TestAppRun✅ passed
com/rm-hull/git-commit-summary/internal/config.TestLoad/Defaults✅ passed
com/rm-hull/git-commit-summary/internal/config.TestLoad/WithEnvironmentVariables✅ passed
com/rm-hull/git-commit-summary/internal/config.TestLoad✅ passed
com/rm-hull/git-commit-summary/internal/llm_provider.TestNewProvider/GoogleProvider✅ passed
com/rm-hull/git-commit-summary/internal/llm_provider.TestNewProvider/OpenAIProvider✅ passed
com/rm-hull/git-commit-summary/internal/llm_provider.TestNewProvider/UnknownProvider✅ passed
com/rm-hull/git-commit-summary/internal/llm_provider.TestNewProvider✅ passed

@coveralls
Copy link

coveralls commented Oct 31, 2025

Pull Request Test Coverage Report for Build 18959370866

Details

  • 16 of 52 (30.77%) changed or added relevant lines in 7 files are covered.
  • 11 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+32.0%) to 32.047%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/git/commit.go 0 1 0.0%
internal/git/diff.go 0 1 0.0%
internal/ui/text_area.go 0 1 0.0%
main.go 0 5 0.0%
internal/git/client.go 0 9 0.0%
internal/ui/client.go 0 19 0.0%
Files with Coverage Reduction New Missed Lines %
main.go 1 0.0%
internal/app/app.go 10 75.0%
Totals Coverage Status
Change from base Build 18958829788: 32.0%
Covered Lines: 108
Relevant Lines: 337

💛 - Coveralls

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is an excellent refactoring effort to introduce dependency injection, which greatly improves the testability of the application. The introduction of Git and UI interfaces is well-executed, and the new unit tests for app, config, and llm_provider are comprehensive and valuable. The changes are clean and follow the stated goal of the PR. I have a couple of suggestions to further improve the separation of concerns by moving all UI logic out of the core application and into the UI layer.

return git.Commit(edited)
return app.git.Commit(edited)
} else {
color.Println("<fg=red;op=bold>ABORTED!</>")

Choose a reason for hiding this comment

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

medium

Printing the 'ABORTED!' message is a UI concern that should be handled by the ui component. To maintain a clean separation of concerns, consider adding a method to the UI interface for displaying this message (e.g., ShowAbortMessage()) and call it here. This would remove the direct dependency on the color package from the app package for this message.

The spinner implementation is now abstracted behind the `UIClient`
interface, decoupling the core application logic from the underlying
library (`github.com/briandowns/spinner`).

This improves separation of concerns and testability.

*   Introduced `StartSpinner`, `UpdateSpinner`, and `StopSpinner`
    methods on `UIClient`.
*   Implemented spinner management in `internal/ui/client.go`.
@rm-hull rm-hull changed the title refactor(app): Introduce dependency injection tests: Add unit tests & introduce dependency injection Oct 31, 2025
@rm-hull rm-hull changed the title tests: Add unit tests & introduce dependency injection test: Add unit tests & introduce dependency injection Oct 31, 2025
@rm-hull rm-hull merged commit 520731b into main Oct 31, 2025
3 checks passed
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