Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with AboutCsvCmdlets.Koans.ps1 #389

Closed
johnheusinger opened this issue May 17, 2020 · 0 comments · Fixed by #390
Closed

Issues with AboutCsvCmdlets.Koans.ps1 #389

johnheusinger opened this issue May 17, 2020 · 0 comments · Fixed by #390
Labels
Category-Koans Invoking the Great Doubt Issue-Bug 🐛 Something's wrong!

Comments

@johnheusinger
Copy link
Contributor

Describe "Koan Bug, Issue, or Help Request"

Hello,

I noticed a few issues while working through PSKoans\Cmdlets 2\AboutCsvCmdlets.Koans.ps1

Context "The Problematic Assertions"

Typo on line 59 - $TestDrove should be $TestDrive

It 'stores the data accurately' {
    # Now if we read the file as text, let's see what's inside!
    $FileContents = Get-Content -Path "$TestDrove/Data.csv"
...
}

Lines 94 and 101: $Letters and $PipeDelimitedCsvPath are set but never used

BeforeAll {
    $Letters = 'abcdefghijklmnopqrstuvwxyz'

    $Objects = foreach ($number in 1..5) {
        [bigint]$number
    }

    $CsvPath = "$TestDrive/Data.csv"
    $PipeDelimitedCsvPath = "$TestDrive/Data2.csv"
...
}

Lines 109 and 114: GetType() returns an object, not a string, so the Pester tests will always fail. Can be resolved by using GetType().FullName

Also, line 111 should read -Not -BeNullOrEmpty rather than -NotBeNullOrEmpty

It 'imports the stored data as PSCustomObjects' {
    # Our original data type is a .NET numeric type.
    'System.____.____' | Should -Be $Objects[0].GetType()

    $ImportedData | Should -NotBeNullOrEmpty

    # What comes back after the import?
    'System.____.____.____' | Should -Be $ImportedData[0].GetType()
}

Line 153: Need to use -Not -BeNullOrEmpty rather than -NotBeNullOrEmpty

It 'allows you to specify the delimiter' {
...
    $Animals.Name | Should -NotBeNullOrEmpty
    $Animals[0].Animal | Should -Be 'Dog'
    $Animals[1].Name | Should -Be 'Alice'
...
}

Lines 203-208: These tests are failing due to reading #TYPE information from the CSV. Can be resolved by adding -NoTypeInformation on line 201

It 'works the same way as Export-Csv' {
    $CsvString = $Objects | ConvertTo-Csv

    '"____","____"' | Should -Be $CsvString[0]
    '"__","__"' | Should -Be $CsvString[1]
    '"__","__"' | Should -Be $CsvString[2]
    '"__","__"' | Should -Be $CsvString[3]
    '"__","__"' | Should -Be $CsvString[4]
    '"__","__"' | Should -Be $CsvString[5]
}

Context "Additional Information"

Happy to follow up with a pull request to address these

Cheers,
John

@johnheusinger johnheusinger added Category-Koans Invoking the Great Doubt Issue-Discussion Let's talk about it! labels May 17, 2020
@vexx32 vexx32 added Issue-Bug 🐛 Something's wrong! and removed Issue-Discussion Let's talk about it! labels May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category-Koans Invoking the Great Doubt Issue-Bug 🐛 Something's wrong!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants