Skip to content

Conversation

@Marusyk
Copy link
Contributor

@Marusyk Marusyk commented Oct 17, 2017

Fix #5139

@markekraus markekraus requested a review from daxian-dbw October 17, 2017 22:23
@@ -1,73 +1,71 @@
Describe "Export-Csv" -Tags "CI" {
$testObject = @("test","object","array")
$testCsv = Join-Path -Path $TestDrive -ChildPath "output.csv"
Copy link
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
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
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
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
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
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
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" 

Copy link
Contributor Author

@Marusyk Marusyk Oct 18, 2017

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

Copy link
Contributor Author

@Marusyk Marusyk Oct 18, 2017

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

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@markekraus markekraus left a comment

Choose a reason for hiding this comment

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

LGTM

@iSazonov
Copy link
Collaborator

@Marusyk Please resolve merge conflicts.

@Marusyk
Copy link
Contributor Author

Marusyk commented Oct 23, 2017

@iSazonov Done

@markekraus
Copy link
Contributor

appveyor build fail due to #5201

@markekraus
Copy link
Contributor

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

@daxian-dbw
Copy link
Member

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

Copy link
Contributor

@markekraus markekraus left a comment

Choose a reason for hiding this comment

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

LGTM

@iSazonov
Copy link
Collaborator

@daxian-dbw Can we merge the PR?

@daxian-dbw
Copy link
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
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