Skip to content

test: expand gpgkeystate and storemodel test suites#1499

Merged
annejan merged 5 commits into
mainfrom
test/gpgkeystate-storemodel-tests
May 17, 2026
Merged

test: expand gpgkeystate and storemodel test suites#1499
annejan merged 5 commits into
mainfrom
test/gpgkeystate-storemodel-tests

Conversation

@nogeenharrie
Copy link
Copy Markdown
Contributor

@nogeenharrie nogeenharrie commented May 16, 2026

Summary

  • tst_gpgkeystate: 23 → 27 tests — adds edge-case coverage for parseGpgColonOutput: empty input, pub-without-uid, orphan sub/ssb records, and short lines that should be silently skipped
  • tst_storemodel: 31 → 34 tests — adds setStoreUpdatesPath (verifies setStore() persists the new path), dataEditRoleKeepsGpgExtension (verifies .gpg is only stripped for DisplayRole), and filterHidesNonGpgFile (documents filter behavior for non-.gpg entries)

Test plan

  • make check passes locally (27 gpgkeystate, 36 storemodel tests pass)
  • No new source files modified — tests only

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added tests for GPG colon-output parsing edge cases: empty input returns no entries, public-key records without user IDs produce a single entry with key ID from the pub record, orphaned subkey records are ignored, and short/malformed lines are skipped.
    • Added store-model tests: verify store path updates, ensure edit-mode preserves the .gpg extension, and confirm filter regexes can accept matching non-.gpg filenames.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds seven Qt test slots: four tests for parseGpgColonOutput edge cases (empty input, missing uid, orphan sub/ssb, short malformed lines) and three tests for StoreModel behaviors (store path updates, EditRole .gpg preservation, and filter acceptance with regex matches).

Changes

Test Coverage Expansion

Layer / File(s) Summary
GPG key parsing edge-case tests
tests/auto/gpgkeystate/tst_gpgkeystate.cpp
Four new test slots validate parseGpgColonOutput on empty input, pub without uid, orphan sub/ssb records, and too-short colon lines—each asserting list size and UserInfo fields.
StoreModel behavior tests
tests/auto/model/tst_storemodel.cpp
Three new test slots verify setStore() updates getStore(), that Qt::EditRole preserves a .gpg file extension in returned data, and that filter matching can accept non-.gpg files when the regex matches.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • IJHack/QtPass#911: Both PRs modify tests/auto/gpgkeystate/tst_gpgkeystate.cpp to extend/adjust the unit tests around parseGpgColonOutput.
  • IJHack/QtPass#1495: Adds additional tst_gpgkeystate slots exercising parseGpgColonOutput edge-case parsing logic similar to this PR.
  • IJHack/QtPass#904: Related earlier parsing refactor and tests for parseGpgColonOutput that these new tests continue to exercise.

Suggested labels

size:L

Poem

🐰 I hopped through colon lines at night,
Empty, short, and orphaned—checked each byte,
Four GPG checks and three store tales,
Hopping over edge cases on testing trails,
A happy rabbit, tests passing bright!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: expand gpgkeystate and storemodel test suites' directly and clearly summarizes the main change: adding new test functions to two test suites.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/gpgkeystate-storemodel-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/auto/gpgkeystate/tst_gpgkeystate.cpp`:
- Around line 479-489: The test parseGpgColonOutputPubWithoutUid should assert
that the UserInfo.name is populated from the pub record's userid field (field
index 9); update the test in tst_gpgkeystate::parseGpgColonOutputPubWithoutUid
to call parseGpgColonOutput(...), then add a QVERIFY/QCOMPARE verifying
result.first().name == QStringLiteral("Name Only") (or equivalent) to ensure
parseGpgColonOutput sets the name when no uid record exists.

In `@tests/auto/model/tst_storemodel.cpp`:
- Line 50: The test named filterHidesNonGpgFile has a contradictory name vs
behavior (it actually verifies a non-.gpg file is accepted when the regex
matches); rename the test to reflect the asserted behavior (e.g.,
filterAcceptsNonGpgFileWhenRegexMatches) and update the function declaration,
definition, and any references/registrations to use the new name (change the
prototype void filterHidesNonGpgFile(); and its implementation and any test
suite entries to void filterAcceptsNonGpgFileWhenRegexMatches();).
- Around line 530-534: Replace the tautological QCOMPARE assertions with
descriptive QVERIFY2 checks that include explicit failure messages: assert that
sm.getStore() equals tempDir.path() after construction and equals newPath after
calling sm.setStore(newPath), using statements that call QVERIFY2(condition,
"message") where the message names the expectation (e.g. "store should default
to temporary directory: expected <tempDir> but was <actual>" and "store should
update to substore after setStore: expected <newPath> but was <actual>"). Ensure
you reference the same methods/variables from the diff (sm.getStore(),
sm.setStore(newPath), tempDir.path(), newPath) when building the condition and
message.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4fe99ff6-7475-49c9-b0fa-30f3b1a6ef76

📥 Commits

Reviewing files that changed from the base of the PR and between 8e94e0e and 7bd3578.

📒 Files selected for processing (2)
  • tests/auto/gpgkeystate/tst_gpgkeystate.cpp
  • tests/auto/model/tst_storemodel.cpp

Comment thread tests/auto/model/tst_storemodel.cpp Outdated
Comment thread tests/auto/model/tst_storemodel.cpp Outdated
@coveralls
Copy link
Copy Markdown

coveralls commented May 16, 2026

Coverage Status

coverage: 55.418%. remained the same — test/gpgkeystate-storemodel-tests into main

@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
437 1 436 4
View the top 1 failed test(s) by shortest run time
tst_gpgkeystate::parseGpgColonOutputPubWithoutUid
Stack Traces | 0s run time
Compared values are not the same

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 2 file(s) based on 3 unresolved review comments.

Files modified:

  • tests/auto/gpgkeystate/tst_gpgkeystate.cpp
  • tests/auto/model/tst_storemodel.cpp

Commit: baabea3165b13522463804d29c5deca3ecef68e8

The changes have been pushed to the test/gpgkeystate-storemodel-tests branch.

Time taken: 2m 27s

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/auto/gpgkeystate/tst_gpgkeystate.cpp`:
- Around line 479-490: The test
tst_gpgkeystate::parseGpgColonOutputPubWithoutUid uses input where the username
is in the wrong colon field (index 12) while parseGpgColonOutput reads the name
from GPG_FIELD_USERID (field index 9); update the test's input string in
parseGpgColonOutputPubWithoutUid so the "Name Only" token appears in the ninth
colon-delimited field (the userid field) matching parseGpgColonOutput's
expectations, ensuring the QCOMPARE on result.first().name passes.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Pro

Run ID: d9183b85-ae91-42fe-8d99-59de8519b36a

📥 Commits

Reviewing files that changed from the base of the PR and between 7bd3578 and baabea3.

📒 Files selected for processing (2)
  • tests/auto/gpgkeystate/tst_gpgkeystate.cpp
  • tests/auto/model/tst_storemodel.cpp

Comment thread tests/auto/gpgkeystate/tst_gpgkeystate.cpp
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • tests/auto/gpgkeystate/tst_gpgkeystate.cpp

Commit: 3e41abbaf8e9c58caf0d86895c25051486725dbd

The changes have been pushed to the test/gpgkeystate-storemodel-tests branch.

Time taken: 1m 28s

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
tests/auto/gpgkeystate/tst_gpgkeystate.cpp (1)

479-490: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Field index mismatch persists in test data.

This issue was previously flagged: "Name Only" is placed at field index 10, but the test comment (line 481) and the implementation expect the userid at field index 9 (GPG_FIELD_USERID). The test input should place "Name Only" at field 9.

🔧 Corrected test input
   const QString input =
-      QStringLiteral("pub:u:4096:1:NOUIDKEY1:1774947438:::u:Name Only:\n");
+      QStringLiteral("pub:u:4096:1:NOUIDKEY1:1774947438:::u:Name Only::\n");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/auto/gpgkeystate/tst_gpgkeystate.cpp` around lines 479 - 490, The test
tst_gpgkeystate::parseGpgColonOutputPubWithoutUid has the userid placed in the
wrong colon field (it's currently at field index 10); update the test input
string passed to parseGpgColonOutput so the "Name Only" value appears at
GPG_FIELD_USERID (field index 9) in the pub record line (i.e. shift the empty
field so the userid occupies the 9th colon-separated slot), keeping the rest of
the record intact so the assertions about key_id and name still hold.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@tests/auto/gpgkeystate/tst_gpgkeystate.cpp`:
- Around line 479-490: The test
tst_gpgkeystate::parseGpgColonOutputPubWithoutUid has the userid placed in the
wrong colon field (it's currently at field index 10); update the test input
string passed to parseGpgColonOutput so the "Name Only" value appears at
GPG_FIELD_USERID (field index 9) in the pub record line (i.e. shift the empty
field so the userid occupies the 9th colon-separated slot), keeping the rest of
the record intact so the assertions about key_id and name still hold.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Pro

Run ID: cc81ace6-7ca0-4dcf-bd80-0029c1d39cea

📥 Commits

Reviewing files that changed from the base of the PR and between baabea3 and 3e41abb.

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/auto/model/tst_storemodel.cpp`:
- Around line 548-549: Replace the bare QVERIFY assertions that check file
creation with QVERIFY2 so failures include descriptive messages: change the
assertions that call f.open(QFile::WriteOnly) (variable f using
QFile::WriteOnly) to use QVERIFY2(..., "<descriptive message>") and do the same
for the second occurrence around lines 573-574; update the message to clearly
state what file operation failed (e.g., "Failed to open test file for writing")
to make setup failures explicit.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Pro

Run ID: 08707885-5f05-4756-af26-e7c7a152ad9b

📥 Commits

Reviewing files that changed from the base of the PR and between 3e41abb and 8eaf69f.

📒 Files selected for processing (1)
  • tests/auto/model/tst_storemodel.cpp

Comment thread tests/auto/model/tst_storemodel.cpp Outdated
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • tests/auto/model/tst_storemodel.cpp

Commit: 0b08aa7a8aecdf00f12af9ac58b25c3968db6c1d

The changes have been pushed to the test/gpgkeystate-storemodel-tests branch.

Time taken: 1m 32s

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/auto/model/tst_storemodel.cpp`:
- Around line 569-571: Update the misleading comment to state that the test is
asserting behavior for the explicit "readme" filter (not a claim about any
default empty regex); specifically, replace the sentence that says the default
empty regex “won’t match” with a clear note that because the test sets the
filter to "readme", a plain text file without a .gpg extension should not pass
the filter unless the filter explicitly matches its basename (i.e., the test
only covers the explicit "readme" filter behavior).
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Pro

Run ID: 56e06083-ae96-4a3f-9df8-ddad65934c6f

📥 Commits

Reviewing files that changed from the base of the PR and between 8eaf69f and 0b08aa7.

📒 Files selected for processing (1)
  • tests/auto/model/tst_storemodel.cpp

Comment thread tests/auto/model/tst_storemodel.cpp Outdated
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • tests/auto/model/tst_storemodel.cpp

Commit: 6dc9421cf9eb0cffffd486a54956b3937fa1dbf2

The changes have been pushed to the test/gpgkeystate-storemodel-tests branch.

Time taken: 1m 36s

coderabbitai Bot and others added 5 commits May 17, 2026 20:01
Fixed 2 file(s) based on 3 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
Fix clang-format violations in the two new test additions:
- tst_storemodel: reflow two over-long qPrintable/QStringLiteral
  argument lines in setStoreUpdatesPath

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@annejan annejan force-pushed the test/gpgkeystate-storemodel-tests branch from 6dc9421 to a60bec2 Compare May 17, 2026 18:07
@annejan annejan merged commit 13f7782 into main May 17, 2026
24 of 25 checks passed
@annejan annejan deleted the test/gpgkeystate-storemodel-tests branch May 17, 2026 18:21
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