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

Export-Csv Test Improvements#5150

Merged
iSazonov merged 5 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
Marusyk:masterMarusyk/PowerShell:masterCopy head branch name to clipboard
Oct 26, 2017
Merged

Export-Csv Test Improvements#5150
iSazonov merged 5 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
Marusyk:masterMarusyk/PowerShell:masterCopy head branch name to clipboard

Conversation

@Marusyk

@Marusyk Marusyk commented Oct 17, 2017

Copy link
Copy Markdown
Contributor

Fix #5139

@markekraus markekraus requested a review from daxian-dbw October 17, 2017 22:23
@@ -3,71 +3,69 @@ Describe "Export-Csv" -Tags "CI" {
$testCsv = Join-Path -Path $TestDrive -ChildPath "output.csv"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please put the two lines in BeforeAll block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done


It "Should be able to be called without error" {
{ $testObject | Export-Csv $testCsv } | Should Not Throw
{ $testObject | Export-Csv $testCsv } | Should Not Throw

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add -ErrorAction Stop.

Export-Csv $testCsv -ErrorAction Stop

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done


It "Should throw if an output file isn't specified" {
{ $testObject | Export-Csv -ErrorAction SilentlyContinue } | Should Throw
{ $testObject | Export-Csv -ErrorAction SilentlyContinue } | ShouldBeErrorId "CannotSpecifyPathAndLiteralPath,Microsoft.PowerShell.Commands.ExportCsvCommand"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use -ErrorAction Stop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

$piped = Get-Content $testCsv

$piped[0] | Should Match ".String"
$piped[0] | Should be "#TYPE System.String"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use:

$piped[0] | Should BeExactly "#TYPE System.String" 

@Marusyk Marusyk Oct 18, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

$switch = Get-Content $testCsv

$switch[0] | Should Match ".Object"
$switch[0] | Should Match ".Object"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use something like:

$piped[0] | Should BeExactly "#TYPE System.Object" 

@Marusyk Marusyk Oct 18, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. But "#TYPE System.Object[]"

It "Should be able to use the epcsv alias without error" {
{ $testObject | Export-Csv -Path $testCsv } | Should Not Throw
{ $testObject | epcsv -Path $testCsv } | Should Not Throw
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please remove the test at all - we have another file for alias tests.

{ $testObject | epcsv -Path $testCsv } | Should Not Throw
}

It "Should have the same information when using the alias vs the cmdlet" {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please remove the test at all - we have another file for alias tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@iSazonov iSazonov self-assigned this Oct 18, 2017
}
}

It "Should have the same information when using the alias vs the cmdlet" {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please remove the alias test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done


It "Should be able to use the epcsv alias without error" {
{ $testObject | Export-Csv -Path $testCsv } | Should Not Throw
for ( $i = 0; $i -lt $testCsv.Length; $i++) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder why we use $testCsv.Length?
I'd expect $expected.Count.
Your thoughts?

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.

I agree and think it should be $expected.Count. I have no clue how the length of the temporary file path string is relevant to anything in this test.

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.

Is there even a need for looping logic here? would calling get-content once and perform 4 explicit tests be better? It seems like creating an array and looping through it (with a for loop no less) is just overkill.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should stop on $expected.Count

# Clean up after yourself
Remove-Item $aliasObject -Force
for ( $i = 0; $i -lt $expected.Count; $i++) {
$(Get-Content $testCsv)[$i] | Should Be $expected[$i]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please correct indentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@markekraus markekraus left a comment

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.

LGTM

@iSazonov

Copy link
Copy Markdown
Collaborator

@Marusyk Please resolve merge conflicts.

@Marusyk

Marusyk commented Oct 23, 2017

Copy link
Copy Markdown
Contributor Author

@iSazonov Done

@markekraus

Copy link
Copy Markdown
Contributor

appveyor build fail due to #5201

@markekraus

Copy link
Copy Markdown
Contributor

@Marusyk Right. that's what I said. the AppVeyor failure is due to the issue noted in #5201

@daxian-dbw

Copy link
Copy Markdown
Member

#5118 has been merged, and I restarted AppVeyor CI for this PR.

@markekraus markekraus left a comment

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.

LGTM

@iSazonov

Copy link
Copy Markdown
Collaborator

@daxian-dbw Can we merge the PR?

@daxian-dbw

Copy link
Copy Markdown
Member

@iSazonov Sorry that I didn't get a chance to review this change (too many notifications since having the code owner filter ...). Please proceed as you see appropriate :)

@iSazonov iSazonov merged commit 282deb7 into PowerShell:master Oct 26, 2017
@iSazonov

Copy link
Copy Markdown
Collaborator

@Marusyk Thanks for your contribution! Welcome back with new PRs.

@iSazonov iSazonov added the Hacktoberfest Potential candidate to participate in Hacktoberfest label Oct 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hacktoberfest Potential candidate to participate in Hacktoberfest

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.