Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

TestHelper\Get-PSModulePathItem Bug #217

Closed
pvs043 opened this issue Apr 5, 2018 · 5 comments
Closed

TestHelper\Get-PSModulePathItem Bug #217

pvs043 opened this issue Apr 5, 2018 · 5 comments
Labels
bug The issue is a bug.

Comments

@pvs043
Copy link
Contributor

pvs043 commented Apr 5, 2018

I'm include your module to appveyor.yml for test my project (https://github.com/pvs043/cMDTBuildLab/blob/dev/appveyor.yml), line 41

After the check error occured:
[00:01:12] Describing TestHelper\Get-PSModulePathItem
[00:01:12] Context When querying for folder path
[00:01:13] [-] Should return the correct folder 140ms
[00:01:13] Expected strings to be the same, but they were different.
[00:01:13] Expected length: 50
[00:01:13] Actual length: 51
[00:01:13] Strings differ at index 50.
[00:01:13] Expected: 'C:\windows\system32\WindowsPowerShell\v1.0\Modules'
[00:01:13] But was: 'C:\windows\system32\WindowsPowerShell\v1.0\Modules\'
[00:01:13] -------------------------------------------------------------^
[00:01:13] 335: Get-PSModulePathItem -Prefix $env:SystemRoot | Should -Be $systemModulePath
[00:01:13] at <ScriptBlock>, C:\projects\Build\cMDTBuildLab\DscResource.Tests\Tests\Unit\TestHelper.Tests.ps1: line 335

This Error occurs after test (line 328):

Describe 'TestHelper\Get-PSModulePathItem' {
    Context 'When querying for folder path' {
        It 'Should return the correct folder' {
            $systemModulePath = Join-Path `
                -Path $env:SystemRoot `
                -ChildPath 'system32\WindowsPowerShell\v1.0\Modules'

            Get-PSModulePathItem -Prefix $env:SystemRoot | Should -Be $systemModulePath
        }
    }

What about to change hardcoded "-ChildPath 'system32\WindowsPowerShell\v1.0\Modules" to "-ChildPath 'system32\WindowsPowerShell\v1.0\Modules\"? (add slash to end)

@PlagueHO
Copy link
Collaborator

PlagueHO commented Apr 5, 2018

I started getting this issue as well on my Windows 10 machine. But this test doesn't seem to fail on AppVeyor. So adding the slash might cause this to fail on AppVeyor.

@pvs043
Copy link
Contributor Author

pvs043 commented Apr 6, 2018

@PlagueHO, this issue occurs on AppVeyor: https://ci.appveyor.com/project/pvs043/cmdtbuildlab/branch/dev?fullLog=true (line 498)

I spent test at Windows 2016:
PS C:\windows\system32> Get-PSModulePathItem -Prefix $env:SystemRoot C:\windows\system32\WindowsPowerShell\v1.0\Modules
Slash is absent!

Thus, suggest doing check on both options: with slash and without.

@PlagueHO
Copy link
Collaborator

PlagueHO commented Apr 6, 2018

@pvs043 - I don't get this issue on AppVeyor, but I do not specify the AppVeyor build worker image, which results in using Visual Studio 2015. It looks like you're using wmf 5 build worker. So I wonder if there is a difference here.

But yes, I agree, we should check for both.

@pvs043
Copy link
Contributor Author

pvs043 commented Apr 6, 2018

My patch:

(Get-PSModulePathItem -Prefix $env:SystemRoot).TrimEnd('\') | Should -Be $systemModulePath

@johlju johlju added bug The issue is a bug. in progress The issue is being actively worked on by someone. labels Apr 22, 2018
johlju pushed a commit that referenced this issue Apr 23, 2018
- Changed Get-PSModulePathItem to trim end back slash (issue #217)
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Apr 23, 2018
@johlju
Copy link
Contributor

johlju commented Apr 23, 2018

This was resolved in PR #221

@johlju johlju closed this as completed Apr 23, 2018
johlju added a commit to johlju/DscResource.Tests that referenced this issue May 1, 2018
- Fix codecov no longer generates an error message when uploading test
  coverage (issue PowerShell#217).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug The issue is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants