ticketmaster / poshspec

Infrastructure Testing DSL running in Pester
MIT License
183 stars 32 forks source link

Adds New Functions #58

Closed stefanhenseler closed 4 years ago

stefanhenseler commented 6 years ago

I've added some new functions over the last months.

cdhunt commented 6 years ago

@synax These are all great additions. Thanks! Can you add tests for each function?

stefanhenseler commented 6 years ago

Hey, sure, totally forgot them. Will add them this week. cheers

stefanhenseler commented 6 years ago

Sorry for the delay. I've added tests for the new functions.

cdhunt commented 6 years ago

@synax 3 tests fail for me. The should exist functionality was rolled back a while ago because it broke things.

    Context SoftwareProduct
      [+] Should return the correct test Name 78ms
      [-] Should return the correct test Expression 90ms
        Expected strings to be the same, but they were different.
        Expected length: 270
        Actual length:   59
        Strings differ at index 0.
        Expected: '@('HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\\Software\Microsoft\Wind
ows\CurrentVersion\Uninstall\*') | Where-Object { Test-Path  } | Get-ItemProperty | Where-Object DisplayName -Match 'Microsoft
 .NET Framework 4.6.1' | Should Exist'
        But was:  'TestSoftware Microsoft .NET Framework 4.6.1  | Should Exist'
        -----------^
        428:                 $results.Expression | Should Be "@('HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\U
ninstall\*','HKLM:\\Software\Microsoft\Windows\CurrentVersion\Uninstall\*') | Where-Object { Test-Path $_ } | Get-ItemProperty
 | Where-Object DisplayName -Match 'Microsoft .NET Framework 4.6.1' | Should Exist"
        at Invoke-LegacyAssertion, C:\Program Files\WindowsPowerShell\Modules\pester\4.3.1\Functions\Assertions\Should.ps1: li
ne 188
        at <ScriptBlock>, C:\source\GitHub\poshspec\Tests\poshspec.Tests.ps1: line 428

    Context SoftwareProduct w/Property
      [+] Should return the correct test Name 223ms
      [-] Should return the correct test Expression 19ms
        Expected strings to be the same, but they were different.
        Expected length: 326
        Actual length:   129
        Strings differ at index 0.
        Expected: '@('HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\\Software\Microsoft\Wind
ows\CurrentVersion\Uninstall\*') | Where-Object { Test-Path  } | Get-ItemProperty | Where-Object DisplayName -Match 'Microsoft
 .NET Framework 4.6.1' | Select-Object -ExpandProperty 'DisplayVersion' | Should Be 4.6.01055'
        But was:  'TestSoftware Microsoft .NET Framework 4.6.1 DisplayVersion | Select-Object -ExpandProperty 'DisplayVersion'
 | Should Be 4.6.01055'
        -----------^
        441:                 $results.Expression | Should Be "@('HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\U
ninstall\*','HKLM:\\Software\Microsoft\Windows\CurrentVersion\Uninstall\*') | Where-Object { Test-Path $_ } | Get-ItemProperty
 | Where-Object DisplayName -Match 'Microsoft .NET Framework 4.6.1' | Select-Object -ExpandProperty 'DisplayVersion' | Should
Be 4.6.01055"
        at Invoke-LegacyAssertion, C:\Program Files\WindowsPowerShell\Modules\pester\4.3.1\Functions\Assertions\Should.ps1: li
ne 188
        at <ScriptBlock>, C:\source\GitHub\poshspec\Tests\poshspec.Tests.ps1: line 441
    Context PSModule
      [+] Should return the correct test Name 67ms
      [-] Should return the correct test Expression 53ms
        Expected strings to be the same, but they were different.
        Expected length: 172
        Actual length:   160
        Strings differ at index 155.
        Expected: 'Get-Module -Name WorkplaceValidation -ListAvailable -ErrorAction SilentlyContinue | Select-Object -First 1
| Select-Object -ExpandProperty 'Path' | should not benullorempty'
        But was:  'Get-Module -Name WorkplaceValidation -ListAvailable -ErrorAction SilentlyContinue | Select-Object -First 1
| Select-Object -ExpandProperty 'Path' | Should Exist'
        ----------------------------------------------------------------------------------------------------------------------
------------------------------------------------^
        581:                 $results.Expression | Should Be "Get-Module -Name WorkplaceValidation -ListAvailable -ErrorAction
 SilentlyContinue | Select-Object -First 1 | Select-Object -ExpandProperty 'Path' | should not benullorempty"
        at Invoke-LegacyAssertion, C:\Program Files\WindowsPowerShell\Modules\pester\4.3.1\Functions\Assertions\Should.ps1: li
ne 188
        at <ScriptBlock>, C:\source\GitHub\poshspec\Tests\poshspec.Tests.ps1: line 581