-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add new tests for Get-ChildItem (FileSystemProvider) #11602
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
Add new tests for Get-ChildItem (FileSystemProvider) #11602
Conversation
test/powershell/Modules/Microsoft.PowerShell.Management/FileSystemProviderExtended.Tests.ps1
Outdated
Show resolved
Hide resolved
80f49a7 to
9a1972f
Compare
test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1
Show resolved
Hide resolved
|
@JamesWTruher Could you please review. |
SteveL-MSFT
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.
Half way through reviewing
test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1
Show resolved
Hide resolved
| BeforeAll { | ||
| $restoreLocation = Get-Location | ||
|
|
||
| $DirSep = [io.path]::DirectorySeparatorChar |
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.
| $DirSep = [io.path]::DirectorySeparatorChar | |
| $DirSep = [IO.Path]::DirectorySeparatorChar |
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.
Done.
| It "Get-ChildItem -Path -Force" { | ||
| $result = Get-ChildItem -Path $rootDir -Force | ||
| $result.Count | Should -Be 5 | ||
| $result | Where-Object Name -eq "filehidden1.doc" | Should -Not -BeNullOrEmpty |
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.
| $result | Where-Object Name -eq "filehidden1.doc" | Should -Not -BeNullOrEmpty | |
| $result.Name | Should -Contain "filehidden1.doc" |
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.
Done.
| $result = Get-ChildItem -Path $rootDir -Name -Force | ||
| $result.Count | Should -Be 5 | ||
| $result | Should -BeOfType [string] | ||
| $result | Where-Object { $_ -eq "filehidden1.doc" } | Should -Not -BeNullOrEmpty |
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.
| $result | Where-Object { $_ -eq "filehidden1.doc" } | Should -Not -BeNullOrEmpty | |
| $result.Name | Should -Contain "filehidden1.doc" |
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.
Done.
test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1
Show resolved
Hide resolved
| It "Get-ChildItem -Path -Recurse -Hidden" { | ||
| $result = Get-ChildItem -Path $rootDir -Recurse -Hidden | ||
| $result.Count | Should -Be 4 | ||
| $result | Where-Object { $_.Name -eq "filehidden1.doc" -and $_.psobject.TypeNames[0] -eq "System.IO.FileInfo"} | Should -Not -BeNullOrEmpty |
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.
| $result | Where-Object { $_.Name -eq "filehidden1.doc" -and $_.psobject.TypeNames[0] -eq "System.IO.FileInfo"} | Should -Not -BeNullOrEmpty | |
| $result.Where{ $_.Name -eq "filehidden1.doc"} | Should -BeOfType [System.IO.FileInfo] |
Same for below
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.
Done.
Sorry, last commit is large (include style changes too). |
test/powershell/Modules/Microsoft.PowerShell.Management/FileSystemProviderExtended.Tests.ps1
Show resolved
Hide resolved
|
|
||
| Set-Location $rootDir | ||
|
|
||
| New-Item -Path "file1.txt" -ItemType File > $null |
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.
Would it be better to have the filenames in a hashtable with their attribute so that you can verify the filenames are returned later in the tests? Then you could also just loop through the hashtable to create the files instead of having separate lines.
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 see your point but I don't want complicate the test code because (1) there are issues we want to fix in near future, (2) there are issues we want to fix in FileSystem provider V2 future - so simple linear tests will simplify our work in future.
|
@SteveL-MSFT Please continue your review. |
1 similar comment
|
@SteveL-MSFT Please continue your review. |
|
🎉 Handy links: |
PR Summary
Add new tests for better code coverage in SessionStateContainer.cs and FileSystemProvider.cs.
PR Context
I prepare a code to address issue #9119 but we have not tests to cover the code paths at all. To avoid regressions we should merge the new tests before new code will be pulled.
Some bugs (#9126 and #3304) was discovered, the new tests was marked as pending.
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.