Skip to content

Conversation

@iSazonov
Copy link
Collaborator

@iSazonov iSazonov commented Jan 16, 2020

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

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

@JamesWTruher Could you please review.

Copy link
Member

@SteveL-MSFT SteveL-MSFT left a 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

BeforeAll {
$restoreLocation = Get-Location

$DirSep = [io.path]::DirectorySeparatorChar
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$DirSep = [io.path]::DirectorySeparatorChar
$DirSep = [IO.Path]::DirectorySeparatorChar

Copy link
Collaborator Author

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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$result | Where-Object Name -eq "filehidden1.doc" | Should -Not -BeNullOrEmpty
$result.Name | Should -Contain "filehidden1.doc"

Copy link
Collaborator Author

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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$result | Where-Object { $_ -eq "filehidden1.doc" } | Should -Not -BeNullOrEmpty
$result.Name | Should -Contain "filehidden1.doc"

Copy link
Collaborator Author

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 -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
Member

Choose a reason for hiding this comment

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

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
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@ghost 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
@iSazonov
Copy link
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
Member

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.

Copy link
Collaborator Author

@iSazonov iSazonov Jan 30, 2020

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.

@iSazonov
Copy link
Collaborator Author

iSazonov commented Feb 4, 2020

@SteveL-MSFT Please continue your review.

1 similar comment
@iSazonov
Copy link
Collaborator Author

@SteveL-MSFT Please continue your review.

@iSazonov iSazonov merged commit 9770477 into PowerShell:master Feb 12, 2020
@iSazonov iSazonov deleted the tests-filesystemprovider-dir branch February 12, 2020 03:17
@ghost
Copy link

ghost commented Mar 26, 2020

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

Handy links:

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