Fix four wrong statements in the tutorial - #465
Open
nohwnd wants to merge 1 commit into
Open
Conversation
The -ModuleName warning claimed a mock without -ModuleName never errors. That holds for a command that also exists outside the module, like Import-Csv, but the box sits under the Get-PlanetData example, and Get-PlanetData is private, so Mock cannot find it at all and you get CommandNotFoundException. Split the two cases. The CI page said 26 tests across six test files. It is seven, Pester prints "Running tests from 7 files." The -Because example showed Should-Be 8 and then a failure saying it got 9. At that point Get-Planet returns 8, so the line passes and the printed failure cannot happen. Say to break it, and print the failure the right way round. Dot-sourcing Get-PlanetDistance.ps1 does not fail immediately. The dot-source succeeds and the later call fails, once per command it cannot resolve. Also create the scratch folder before writing the ordering demonstration into it, it was the only folder in the tutorial without a New-Item step. Fix #460
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #460
Stacked on #464, review that one first. The diff against
mainwill look bigger than it is until #464 merges.I verified the tutorial by running it against Pester 6.1.0. Almost everything holds up, every test total and every coverage number is right. These four were wrong.
The
-ModuleNamewarning. It said "Nothing errors. The mock is simply never used, and the real command runs instead." True for a command that also exists outside the module, and the box sits under theGet-PlanetDataexample, which is private. ThereMockcannot find the command at all:Both cases are now in the box, because the old advice sent you looking for a silent no-op when what you actually got was an error.
"26 tests across six test files" is seven. Pester prints
Running tests from 7 files.The
-Becauseexample showedShould-Be 8followed by a failure saying it got9.Get-Planetreturns 8 at that point, so that line passes and the printed failure cannot happen. It now says to break it, and prints the message the right way round:Dot sourcing does not fail immediately. The dot-source succeeds, and the call fails afterwards on three commands rather than one.
Also added the missing
New-Itemfor thescratchfolder, it was the only folder in the tutorial you were told to write into without being told to create it.Verification
Ran the tutorial from an empty folder on pwsh 7.5.5 with Pester 6.1.0 and reproduced each of the four, then confirmed the replacement text matches the real output. Site builds.
🤖