Skip to content

test(gmail): add unit tests for +triage argument parsing#445

Merged
jpoehnelt merged 1 commit intogoogleworkspace:mainfrom
anshul-garg27:test/gmail-triage-coverage
Mar 13, 2026
Merged

test(gmail): add unit tests for +triage argument parsing#445
jpoehnelt merged 1 commit intogoogleworkspace:mainfrom
anshul-garg27:test/gmail-triage-coverage

Conversation

@anshul-garg27
Copy link
Contributor

Summary

  • Add 8 unit tests for gmail +triage argument parsing — previously the only helper file with zero test coverage
  • Tests cover: default/explicit/invalid --max, --query override, --labels flag, and --format selection

Details

src/helpers/gmail/triage.rs had no #[cfg(test)] module. While the core logic involves network calls (Gmail API), the argument parsing and format selection are purely deterministic and worth covering.

Tests added

  • defaults_max_to_20_and_query_to_unread — verifies default values
  • explicit_max_overrides_default--max 5 parses correctly
  • non_numeric_max_falls_back_to_20--max abc silently falls back
  • custom_query_overrides_default--query 'from:boss' works
  • labels_flag_defaults_to_false — default behavior
  • labels_flag_set_when_passed--labels sets the flag
  • format_defaults_to_table_when_absent — table is the default
  • format_json_when_specified--format json switches output

triage.rs was the only helper file with zero test coverage.
Add tests for: default max (20), explicit max, non-numeric max
fallback, custom query, labels flag, and output format selection.
@googleworkspace-bot googleworkspace-bot added the area: core Core CLI parsing, commands, error handling, utilities label Mar 12, 2026
@gemini-code-assist
Copy link
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 gmail +triage command by introducing a comprehensive set of unit tests for its argument parsing logic. This ensures that various command-line inputs are handled correctly, improving the reliability and predictability of the tool's behavior without altering its core functionality.

Highlights

  • Unit Test Coverage: Added 8 new unit tests for the gmail +triage argument parsing, addressing a previously untested helper file.
  • Argument Parsing Validation: Tests cover various scenarios for --max (default, explicit, and non-numeric fallback), --query overrides, the --labels flag, and --format selection (default table and explicit JSON).
  • Documentation Update: Updated the module-level documentation for src/helpers/gmail/triage.rs to provide a more detailed description of its functionality.
Changelog
  • .changeset/test-gmail-triage-coverage.md
    • Added a new changeset file to document the addition of unit tests for Gmail triage argument parsing.
  • src/helpers/gmail/triage.rs
    • Added a new #[cfg(test)] module containing 8 unit tests for argument parsing.
    • Updated the module-level documentation with a more detailed description of the +triage helper's capabilities.
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 Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2026

🦋 Changeset detected

Latest commit: 84cdd27

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
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 adds valuable unit tests for the gmail +triage argument parsing. However, the current implementation duplicates the parsing logic from the production code within the tests, which makes them brittle. I've provided a suggestion to refactor the tests to centralize this logic, making them cleaner and more maintainable. This also highlights an opportunity to make the production code more testable by extracting the argument parsing logic.

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.39%. Comparing base (e3e1e86) to head (84cdd27).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #445      +/-   ##
==========================================
+ Coverage   67.22%   67.39%   +0.16%     
==========================================
  Files          38       38              
  Lines       16679    16764      +85     
==========================================
+ Hits        11213    11298      +85     
  Misses       5466     5466              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpoehnelt jpoehnelt merged commit 957b999 into googleworkspace:main Mar 13, 2026
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Core CLI parsing, commands, error handling, utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants