Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Increase code coverage of Get-ChildItem on file system.#4342

Merged
adityapatwardhan merged 3 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
jeffbi:tests-4148-gciCopy head branch name to clipboard
Aug 1, 2017
Merged

Increase code coverage of Get-ChildItem on file system.#4342
adityapatwardhan merged 3 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
jeffbi:tests-4148-gciCopy head branch name to clipboard

Conversation

@jeffbi

@jeffbi jeffbi commented Jul 25, 2017

Copy link
Copy Markdown

Addresses part of #4148.

Using the -Name parameter on Get-ChildItem exercises a part of the file system provider code not previously covered by tests.


It "Verity Get-ChildItem can get the name of a specified item." {
$fileName = Get-ChildItem $testFile -Name
$fileName | Should BeExactly $fileName

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This compares to itself.
I suggest calling Get-ChildItem twice, once with -Name to get the name string and once without to get the fileinfo. The test would look something like the following:
$filename | Should BeExactly $fileInfo.Name

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yikes! Bad typo on my part. That should have been $filename | Should BeExactly $testFile. Is making that change sufficient, or would you prefer the dual-call method?

@dantraMSFT

Copy link
Copy Markdown
Contributor

You're better off comparing the returned value against the name property since, I believe, that's the intent.

@jeffbi

jeffbi commented Jul 25, 2017

Copy link
Copy Markdown
Author

Well, the intent was to check that I got the item I asked for, which is why I was comparing against $testFile. But I'll go ahead with your recommendation.

@dantraMSFT

Copy link
Copy Markdown
Contributor

Sorry jeffbi; I should have been clearer. When I said the intent of -Name, I mean the intent is to return the Name property of the FileInfo object.
The current implementation of FileInfo 'does' preserve the file name as it was passed in; however, since it's not documented explicitly, I avoid depending on it.
Additionally, I would expect the test to succeed with other values, such as .\filename.txt, ./filename.txt, and /etc/filename.txt
I hope that clarifies my feedback.

@adityapatwardhan adityapatwardhan merged commit 10a27b8 into PowerShell:master Aug 1, 2017
@jeffbi jeffbi deleted the tests-4148-gci branch August 1, 2017 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.