FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add new tests for Get-ChildItem (FileSystemProvider) by iSazonov · Pull Request #11602 · PowerShell/PowerShell · GitHub

Add new tests for Get-ChildItem (FileSystemProvider) - #11602

Merged
Ilya (iSazonov) merged 5 commits into
PowerShell:masterfrom
iSazonov:tests-filesystemprovider-dir
Feb 12, 2020
Merged

Add new tests for Get-ChildItem (FileSystemProvider)#11602
Ilya (iSazonov) merged 5 commits into
PowerShell:masterfrom
iSazonov:tests-filesystemprovider-dir

Conversation

Ilya (iSazonov) commented Jan 16, 2020
edited
Loading

Copy link
Copy Markdown
Collaborator

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

Ilya (iSazonov) added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Jan 16, 2020
Ilya (iSazonov) added this to the 7.1.0-preview.1 milestone Jan 16, 2020
Ilya (iSazonov) self-assigned this Jan 16, 2020
Ilya (iSazonov) force-pushed the tests-filesystemprovider-dir branch from 80f49a7 to 9a1972f Compare January 22, 2020 05:25

Copy link
Copy Markdown
Collaborator Author

James Truher (@JamesWTruher) Could you please review.

Steve Lee (SteveL-MSFT) 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Half way through reviewing

BeforeAll {
$restoreLocation = Get-Location

$DirSep = [io.path]::DirectorySeparatorChar

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
$DirSep = [io.path]::DirectorySeparatorChar
$DirSep = [IO.Path]::DirectorySeparatorChar

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
$result | Where-Object Name -eq "filehidden1.doc" | Should -Not -BeNullOrEmpty
$result.Name | Should -Contain "filehidden1.doc"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
$result | Where-Object { $_ -eq "filehidden1.doc" } | Should -Not -BeNullOrEmpty
$result.Name | Should -Contain "filehidden1.doc"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done.

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

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
$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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done.

ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Jan 28, 2020

Copy link
Copy Markdown
Collaborator Author

Half way through reviewing

Sorry, last commit is large (include style changes too).


Set-Location $rootDir

New-Item -Path "file1.txt" -ItemType File > $null

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Ilya (iSazonov) Jan 30, 2020
edited
Loading

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown
Collaborator Author

Steve Lee (@SteveL-MSFT) Please continue your review.

1 similar comment

Copy link
Copy Markdown
Collaborator Author

Steve Lee (@SteveL-MSFT) Please continue your review.

Ilya (iSazonov) merged commit 9770477 into PowerShell:master Feb 12, 2020
Ilya (iSazonov) deleted the tests-filesystemprovider-dir branch February 12, 2020 03:17

Copy link
Copy Markdown

🎉v7.1.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
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

Labels

CL-Test Indicates that a PR should be marked as a test change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL