Skip to content

test: retry on the asserted property, not just the count - #72

Merged
StuartMeeks merged 1 commit into
mainfrom
fix/61-restore-selection-flake
Aug 25, 2026
Merged

test: retry on the asserted property, not just the count#72
StuartMeeks merged 1 commit into
mainfrom
fix/61-restore-selection-flake

Conversation

@StuartMeeks

Copy link
Copy Markdown
Owner

Fixes #61.

Why it flaked

var restored = Assert.Single(await RetryHelper.UntilAsync(() => manager.ExportCredentialsAsync(), r => r.Count == 1));
Assert.True(restored.IsSelected);          // <- not covered by the wait

IsSelected is read from a separate store item — the selection record — written moments earlier by RestoreCredentialAsync. The credential item can become visible before the selection item does, so a count-only predicate lets the assertions run against a half-visible store.

Observed on the macOS leg of PR #60's CI; the identical commit then passed on main, which is what confirmed timing rather than regression.

Fix

The predicate now covers the property being asserted:

r => r.Count == 1 && r[0].IsSelected

Applied to both native backends — libsecret has the same shape and the same exposure, it just hasn't been unlucky yet.

Verification

Build clean, 408 tests (354 passed, 54 skipped) — unchanged; this is a timing fix, not new coverage.

A flake fix can't be proven by a green run, so I'm not claiming it is. What's verifiable is the mechanism: the wait now covers every value the test asserts, so there is no window where the assertions can observe a partially-visible store.

🤖 Generated with Claude Code

RestoreCredentialAsync_Preserves... waited via RetryHelper.UntilAsync with a
`r.Count == 1` predicate and then asserted restored.IsSelected. IsSelected is
read from a separate store item -- the selection record -- written moments
earlier by RestoreCredentialAsync, so the credential item can become visible
before the selection item does. The count-only predicate let the assertions run
against a half-visible store.

Observed on the macOS runner during PR #60's CI, where the identical commit then
passed on main, confirming timing rather than regression.

The predicate now covers what is actually asserted, on both native backends.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@StuartMeeks
StuartMeeks merged commit 605fb06 into main Aug 25, 2026
9 checks passed
@StuartMeeks
StuartMeeks deleted the fix/61-restore-selection-flake branch August 25, 2026 04:02
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.

RestoreCredentialAsync_PreservesAccountIdAndSelection flakes on the macOS runner

1 participant