Skip to content

test(acp): add missing coverage for extensions command error paths#23060

Open
Br1an67 wants to merge 1 commit intogoogle-gemini:mainfrom
Br1an67:test-acp-extensions-error-paths
Open

test(acp): add missing coverage for extensions command error paths#23060
Br1an67 wants to merge 1 commit intogoogle-gemini:mainfrom
Br1an67:test-acp-extensions-error-paths

Conversation

@Br1an67
Copy link
Copy Markdown

@Br1an67 Br1an67 commented Mar 19, 2026

Summary

Adds test coverage for error paths in ACP extension commands (DisableExtensionCommand and UninstallExtensionCommand) that were not previously tested. These commands are in packages/cli/src/acp/commands/extensions.ts.

Details

New test cases (8 total)

DisableExtensionCommand:

  • returns error when disabling fails — verifies error message format when extensionManager.disableExtension() throws (e.g. extension does not exist)
  • returns usage message when no args provided — verifies usage hint is shown
  • reports success when disable succeeds — happy path baseline

UninstallExtensionCommand:

  • returns error when uninstalling a non-existent extension — verifies error message includes extension name and propagated error
  • returns usage message when no args and no --all flag — verifies usage hint
  • reports success when uninstall succeeds — happy path baseline
  • reports "No extensions installed" for --all with empty list — edge case for --all flag with no installed extensions

Approach

Uses a createMockContext() helper that constructs a minimal CommandContext with a mock ExtensionManager (set via Object.setPrototypeOf to pass the instanceof check in the command implementations). This isolates the command logic from the full extension manager infrastructure.

Related Issues

Closes #22934
Related to #22798

How to Validate

npm run test --workspace @google/gemini-cli -- src/acp/commands/extensions.test.ts

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)

Add test coverage for error paths in DisableExtensionCommand and
UninstallExtensionCommand that were not previously tested:

- DisableExtensionCommand: error when disableExtension() throws
  (e.g. extension does not exist)
- UninstallExtensionCommand: error when uninstallExtension() throws
  for a non-existent extension
- Both: usage message when no args provided
- Both: success path verification
- UninstallExtensionCommand: --all with empty extension list

Each test asserts the exact output format including extension name and
propagated error message to prevent regressions in user-facing error
reporting.

Closes google-gemini#22934

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Br1an67 Br1an67 requested a review from a team as a code owner March 19, 2026 04:33
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 significantly enhances the robustness of the CLI's extension management commands by introducing dedicated test coverage for various error conditions and edge cases. By simulating failures and incorrect usage, the changes ensure that DisableExtensionCommand and UninstallExtensionCommand provide clear and accurate feedback to users, improving the overall reliability and user experience of the extension system.

Highlights

  • Expanded Test Coverage: Added comprehensive test coverage for error paths in DisableExtensionCommand and UninstallExtensionCommand within the ACP extension commands.
  • New Test Cases: Introduced 8 new test cases, covering scenarios such as failed disabling/uninstalling, correct usage message display, and successful operations.
  • Mocking Utility: Implemented a createMockContext() helper function to facilitate isolated testing of command logic by providing a mock ExtensionManager.
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.

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.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 19, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Copy Markdown
Contributor

@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 introduces comprehensive test coverage for the error paths and happy paths of DisableExtensionCommand and UninstallExtensionCommand within the ACP extension commands. The new test cases effectively validate the expected behavior, including error message formatting, usage message display, and successful execution. The createMockContext helper provides a clean and isolated environment for testing, ensuring the command logic is thoroughly verified. The changes significantly improve the robustness of the extension management commands by ensuring their error handling is correct and user-friendly. No high or critical severity issues were identified in this change.

@gemini-cli gemini-cli bot added the area/extensions Issues related to Gemini CLI extensions capability label Mar 19, 2026
@Br1an67
Copy link
Copy Markdown
Author

Br1an67 commented Mar 19, 2026

@googlebot I signed it.

@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli bot commented Apr 3, 2026

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383).

We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'.

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community!

@cocosheng-g
Copy link
Copy Markdown
Contributor

@Br1an67, apologies for the bot closing this PR! We have reopened it. Please sync your branch to the latest main and we will have someone review it shortly.

@gemini-cli gemini-cli bot added the help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/extensions Issues related to Gemini CLI extensions capability help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(acp): add missing coverage for extensions command error paths

2 participants