Skip to content

test: add unit tests for GPG key state parsing#911

Merged
annejan merged 3 commits into
mainfrom
ai-findings-autofix/tests-auto-gpgkeystate-tst_gpgkeystate.cpp
Apr 7, 2026
Merged

test: add unit tests for GPG key state parsing#911
annejan merged 3 commits into
mainfrom
ai-findings-autofix/tests-auto-gpgkeystate-tst_gpgkeystate.cpp

Conversation

@annejan
Copy link
Copy Markdown
Member

@annejan annejan commented Apr 7, 2026

Summary

Added comprehensive unit tests for the gpgkeystate module's parseGpgColonOutput() and classifyRecord() functions.

Test Coverage

  • parseMultiKeyPublic - Tests parsing multiple public keys
  • parseSecretKeys - Tests parsing secret keys with have_secret flag
  • parseSingleKey - Tests single key parsing (pub only and pub with fpr)
  • parseKeyRollover - Tests key rollover scenarios (3+ keys)
  • classifyRecord - Tests GPG colon output record classification

Test Data

Includes real-world GPG colon output samples for:

  • Multiple public keys
  • Secret keys with subkeys
  • Key rollover scenarios
  • Various record types (pub, sec, uid, fpr, sub, ssb, grp)

Part of ongoing effort to improve test coverage for gpgkeystate module (issue #904).

Summary by CodeRabbit

  • Tests
    • Updated test assertion error message formatting for improved clarity.

annejan and others added 3 commits April 7, 2026 23:29
…m Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…m Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…m Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 33c5c680-3d3d-43de-868f-0caae0611b93

📥 Commits

Reviewing files that changed from the base of the PR and between 5c2a461 and 766306b.

📒 Files selected for processing (1)
  • tests/auto/gpgkeystate/tst_gpgkeystate.cpp

📝 Walkthrough

Walkthrough

The PR updates test assertion error message formatting in GPG key state tests. String format argument application is modified from simultaneous substitution to sequential chaining across four test functions.

Changes

Cohort / File(s) Summary
Test Assertion Formatting
tests/auto/gpgkeystate/tst_gpgkeystate.cpp
Updated error message formatting in four test slots (parseMultiKeyPublic, parseSecretKeys, parseSingleKey, parseKeyRollover) by switching from .arg(expectedCount, result.size()) to .arg(expectedCount).arg(result.size()).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Poem

🐰 A rabbit's verse on format's grace:
Chains of .arg() line by line,
Sequential substitution—cleaner, fine!
Test messages now aligned just right,
Four slots sparkle with formatted light! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title describes adding unit tests for GPG key state parsing, but the actual changes only fix string formatting in existing test assertions without adding new tests. Update the title to reflect the actual changes, such as 'test: fix string formatting in GPG key state test assertions' or similar.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ai-findings-autofix/tests-auto-gpgkeystate-tst_gpgkeystate.cpp

Comment @coderabbitai help to get the list of available commands and usage tips.

@nogeenhenk nogeenhenk changed the title Potential fixes for 3 code quality findings test: add unit tests for GPG key state parsing Apr 7, 2026
@nogeenhenk nogeenhenk marked this pull request as ready for review April 7, 2026 21:30
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage is 21.044%ai-findings-autofix/tests-auto-gpgkeystate-tst_gpgkeystate.cpp into main. No base build found for main.

@annejan annejan merged commit 6b708ab into main Apr 7, 2026
23 of 24 checks passed
@annejan annejan deleted the ai-findings-autofix/tests-auto-gpgkeystate-tst_gpgkeystate.cpp branch April 7, 2026 21:44
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