-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Adding tests for Remove-Module
#9276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding tests for Remove-Module
#9276
Conversation
|
Not too sure why this is is failing for Remove-Module -Name tests when eveything works locally (running just this test locally and no others): BeforeEach {
Import-Module -Name "$testdrive\Modules\Foo\Foo.psd1" -Force
Import-Module -Name "$testdrive\Modules\Bar\Bar.psd1" -Force
Import-Module -Name "$testdrive\Modules\Baz\Baz.psd1" -Force
(Get-Module -Name "Bar", "Baz", "Foo").Name | Should -BeExactly "Bar", "Baz", "Foo"
}With the following error : For some reason 'Foo' appears twice. |
|
Fixed the CI tests though I'm still not sure why I had two modules named "Foo" in my environment. |
| Import-Module -Name "$testdrive\Modules\Bar\Bar.psd1" -Force | ||
| Import-Module -Name "$testdrive\Modules\Baz\Baz.psd1" -Force | ||
|
|
||
| (Get-Module -Name "Bar", "Baz", "Foo").Name | Should -BeExactly "Bar", "Baz", "Foo", "Foo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that it does that we expect. I suggest join strings and compare.
So all tests should be refactored.
Also please remove the line - all "Should" should be in "It" blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed the second comment.
In regards to the first comment I can confirm that -BeExactly does indeed do what we expect to, at least in the sense that it makes sure that the list of modules we try to get are indeed present (both lists are equal).
iSazonov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one minor comment.
test/powershell/Modules/Microsoft.PowerShell.Core/Remove-Module.Tests.ps1
Show resolved
Hide resolved
remove-module
remove-moduleRemove-Module
|
@pougetat Thanks for your contribution! |
|
@pougetat great job ! The only missing scenario is when you import module with using scripting.Classes.using.tests.ps1#L504 ) |
|
@fMichaleczek Please feel free to contribute more tests |
|
@rjmholt sure ! if i write a test that failed (bug in powershell), what I should do with this test ? |
|
The ideal I think is to open a PR with the test marked as |
* return correct casing of filesystem path during normalization * handle UNC case * handle case to add trailing separator back * add support for NTFS streams syntax * add case-sensitive test * only apply correct casing to directories * handle 8.3 path syntax * fix short path processing * Remove elements which do not work on earlier version on Windows PowerShell (#9411) * Use `Environment.NewLine` for new lines in `ConsoleHost` code (#9392) * Run CodeFormatter for Eventing (#9394) * Run CodeFormatter for MarkdownRender (#9398) * Run CodeFormatter for Security module (#9399) * Run CodeFormatter for WSMan.Runtime (#9401) * Run CodeFormatter for WSMan.Management (#9400) * Allow CI to run on branches with this name pattern: feature* (#9415) * Run CodeFormatter with BraceNewLine,UsingLocation,FormatDocument,NewLineAbove rules (#9393) * Build(deps): Bump NJsonSchema from 9.13.30 to 9.13.34 (#9421) * Build(deps): Bump NJsonSchema from 9.13.34 to 9.13.35 (#9429) Bumps [NJsonSchema](https://github.com/rsuter/NJsonSchema) from 9.13.34 to 9.13.35. - [Release notes](https://github.com/rsuter/NJsonSchema/releases) - [Commits](https://github.com/rsuter/NJsonSchema/commits) Signed-off-by: dependabot[bot] <support@dependabot.com> * Build(deps): Bump Newtonsoft.Json (#9431) Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 12.0.1 to 12.0.2. - [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases) - [Commits](JamesNK/Newtonsoft.Json@12.0.1...12.0.2) Signed-off-by: dependabot[bot] <support@dependabot.com> * Build(deps): Bump Newtonsoft.Json from 12.0.1 to 12.0.2 (#9434) Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 12.0.1 to 12.0.2. - [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases) - [Commits](JamesNK/Newtonsoft.Json@12.0.1...12.0.2) Signed-off-by: dependabot[bot] <support@dependabot.com> * Add Preview assets for msix (#9375) * Adding tests for `Remove-Module` (#9276) * Build(deps): Bump gulp from 4.0.0 to 4.0.1 in /test/common/markdown (#9441) * Move warning message to EndProcessing so it only shows up once (#9385) * Run Codeformatter for SMA (#9402) * Fix the failed test and update 'Publish-TestResults' to make AzDO fail the task when any tests failed (#9457) * Enable building on Kali Linux (#9471) * Build test packages for windows, linux-x64, linux-arm, linux-arm64 and macOS (#9476) * Build(deps): Bump NJsonSchema from 9.13.35 to 9.13.36 (#9478) * Update Release_Process.md Add item for global tool Co-authored-by: Steve Lee <slee@microsoft.com> Co-authored-by: Steve Lee (POWERSHELL) <slee@ntdev.microsoft.com> Co-authored-by: Aditya Patwardhan <adityap@microsoft.com> Co-authored-by: Ilya <darpa@yandex.ru> Co-authored-by: Dongbo Wang <dongbow@microsoft.com> Co-authored-by: null <dependabot[bot]@users.noreply.github.com> Co-authored-by: pougetat <thomas.pouget-abadie@ensimag.grenoble-inp.fr> Co-authored-by: Andrew <anmenaga@microsoft.com>
PR Summary
This PR adds approx 50 tests (+3 seconds when running locally) for the remove-module cmdlet.
If anyone has suggestions for test cases I missed please feel free to comment. Some of the cases listed are quite vague for the moment. My objective is to optimize the
number of tests written / branches tested. I will also screenshot some codeCov results once I get around to running it on the codebase.Tests have been added tests for :
PR Context
This PR is aimed at increasing testing coverage for the module related cmdlets which we would like to refactor down the line.
This issue tracks the refactoring work : #8936
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.