Skip to content

Testing Find-DbaCommand - Restore the index file the Rebuild test overwrites - #10630

Open
andreasjordan wants to merge 1 commit into
developmentfrom
fix-finddbacommand-index-leftover
Open

Testing Find-DbaCommand - Restore the index file the Rebuild test overwrites#10630
andreasjordan wants to merge 1 commit into
developmentfrom
fix-finddbacommand-index-leftover

Conversation

@andreasjordan

Copy link
Copy Markdown
Collaborator

Summary

Find-DbaCommand.Tests.ps1 runs Find-DbaCommand -Pattern snapshot -Rebuild, and the rebuild path writes the regenerated index straight over bin\dbatools-index.json in the module root. When the module runs from a git working copy, that overwrites a tracked release asset - the file is committed only by the release process (v2.8.0 through v2.8.4 in the history) - so every suite run left the tree with a permanent 13 MB modification.

The fix stays in the test: BeforeAll copies the index file to the test temp directory, AfterAll copies it back and removes the backup. The -Rebuild coverage is unchanged - the rebuild still executes against the real file and the assertion still reads its output - only the leftover goes away. Ignoring the file instead would not work (.gitignore has no effect on tracked files), and untracking it would change what the release ships.

Verification

Ran the file via the lab harness: 7/7 green (1 unit, 6 integration), and git status shows a clean bin\dbatools-index.json after the run - before the fix it showed as modified after every run that included this file.

created by Claude and reviewed by Andreas Jordan

🤖 Generated with Claude Code

…rwrites

The "-Rebuild" test regenerates bin\dbatools-index.json in place. That
file is a tracked release asset, committed only by the release process,
so running the test from a git working copy left the tree permanently
modified - a 13 MB binary-looking diff after every suite run.

Back the file up in BeforeAll and restore it in AfterAll. The rebuild
is still exercised for real and its assertion still reads the freshly
generated index; only the leftover goes away.

Verified via the lab harness: 7/7 green, and the working tree is clean
after the run.

(do Find-DbaCommand)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@potatoqualitee potatoqualitee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the complete current head, index backup/restore lifecycle, test isolation behavior, and exact-head CI evidence. The normal repository test path is corrected and no material blocker was found.

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