ticketmaster / poshspec

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

Poshspec Pester Tests broken from PR #44 #48

Closed jgigler closed 7 years ago

jgigler commented 7 years ago

PR #44 broke the following poshspec pester contexts. The AD Commands are failing because the module is not found, and the other functions are failing because the tests weren't updated to reflect the automatic expansion of Exists and Not Exist to Should be notnullorempty, and Should not benullorempty; respectively.

Context                    Describe                        Name
-------                    --------                        ----
One Parameter              Get-PoshspecParam               Should return the correct test Expression
One Parameter with a space Get-PoshspecParam               Should return the correct test Expression
Two Parameters             Get-PoshspecParam               Should return the correct test Expression
Three Parameters           Get-PoshspecParam               Should return the correct test Expression
OU Exists                  Get-PoshSpecADOrganizatinalUnit Error occurred in Context block
OU does not exist          Get-PoshSpecADOrganizatinalUnit Error occurred in Context block
Group Exists               Get-PoshSpecADGroup             Error occurred in Context block
Group does not exist       Get-PoshSpecADGroup             Error occurred in Context block
User Exists                Get-PoshSpecADUser              Error occurred in Context block
User does not exist        Get-PoshSpecADUser              Error occurred in Context block
File                       Test Functions                  Should return the correct test Expression
Registry w/o Properties    Test Functions                  Should return the correct test Expression
Hotfix                     Test Functions                  Should return the correct test Expression
Folder                     Test Functions                  Should return the correct test Expression
SoftwareProduct            Test Functions                  Should return the correct test Expression
SoftwareProduct w/Property Test Functions                  Should return the correct test Expression

Full Results (of Just Errors):

    Context One Parameter
      [+] Should return the correct test Name 37ms
      [-] Should return the correct test Expression 36ms
        Expected string length 42 but was 30. Strings differ at index 25.
        Expected: {Get-Item 'name' | should not benullorempty}
        But was:  {Get-Item 'Name' | Should Exist}
        ------------------------------------^
        at <ScriptBlock>, C:\Users\Administrator\Documents\WindowsPowerShell\Modules\poshspec\2.1.16\Tests\poshspec.Test
s.ps1: line 23
        23:                 $results.Expression | Should Be "Get-Item 'name' | should not benullorempty"

    Context One Parameter with a space
      [+] Should return the correct test Name 27ms
      [-] Should return the correct test Expression 11ms
        Expected string length 50 but was 38. Strings differ at index 33.
        Expected: {Get-Item 'Spaced Value' | should not benullorempty}
        But was:  {Get-Item 'Spaced Value' | Should Exist}
        --------------------------------------------^
        at <ScriptBlock>, C:\Users\Administrator\Documents\WindowsPowerShell\Modules\poshspec\2.1.16\Tests\poshspec.Test
s.ps1: line 35
        35:                 $results.Expression | Should Be "Get-Item 'Spaced Value' | should not benullorempty"

    Context Two Parameters
      [+] Should return the correct test Name 28ms
      [-] Should return the correct test Expression 40ms
        Expected string length 98 but was 86. Strings differ at index 81.
        Expected: {Get-Item 'name' 'Something' | Select-Object -ExpandProperty 'Something' | should not benullorempty}
        But was:  {Get-Item 'Name' 'Something' | Select-Object -ExpandProperty 'Something' | Should Exist}
        --------------------------------------------------------------------------------------------^
        at <ScriptBlock>, C:\Users\Administrator\Documents\WindowsPowerShell\Modules\poshspec\2.1.16\Tests\poshspec.Test
s.ps1: line 47
        47:                 $results.Expression | Should Be "Get-Item 'name' 'Something' | Select-Object -ExpandProperty
 'Something' | should not benullorempty"

    Context Three Parameters
      [+] Should return the correct test Name 35ms
      [-] Should return the correct test Expression 12ms
        Expected string length 102 but was 90. Strings differ at index 85.
        Expected: {Get-Item 'name' 'Something' '1' | Select-Object -ExpandProperty 'Something' | should not benullorempt
y}
        But was:  {Get-Item 'Name' 'Something' '1' | Select-Object -ExpandProperty 'Something' | Should Exist}
        ------------------------------------------------------------------------------------------------^
        at <ScriptBlock>, C:\Users\Administrator\Documents\WindowsPowerShell\Modules\poshspec\2.1.16\Tests\poshspec.Test
s.ps1: line 59
        59:                 $results.Expression | Should Be "Get-Item 'name' 'Something' '1' | Select-Object -ExpandProp
erty 'Something' | should not benullorempty"

  Describing Get-PoshSpecADOrganizatinalUnit

    Context OU Exists
      [-] Error occurred in Context block 55ms
        Could not find Command SearchAd
        At C:\Program Files\WindowsPowerShell\Modules\Pester\4.0.3\Functions\Mock.ps1:850 char:9

    Context OU does not exist
      [-] Error occurred in Context block 55ms
        Could not find Command SearchAd
        At C:\Program Files\WindowsPowerShell\Modules\Pester\4.0.3\Functions\Mock.ps1:850 char:9

  Describing Get-PoshSpecADGroup

    Context Group Exists
      [-] Error occurred in Context block 55ms
        Could not find Command SearchAd
        At C:\Program Files\WindowsPowerShell\Modules\Pester\4.0.3\Functions\Mock.ps1:850 char:9

    Context Group does not exist
      [-] Error occurred in Context block 38ms
        Could not find Command SearchAd
        At C:\Program Files\WindowsPowerShell\Modules\Pester\4.0.3\Functions\Mock.ps1:850 char:9

  Describing Get-PoshSpecADUser

    Context User Exists
      [-] Error occurred in Context block 58ms
        Could not find Command SearchAd
        At C:\Program Files\WindowsPowerShell\Modules\Pester\4.0.3\Functions\Mock.ps1:850 char:9

    Context User does not exist
      [-] Error occurred in Context block 61ms
        Could not find Command SearchAd
        At C:\Program Files\WindowsPowerShell\Modules\Pester\4.0.3\Functions\Mock.ps1:850 char:9

    Context File
      [+] Should return the correct test Name 34ms
      [-] Should return the correct test Expression 10ms
        Expected string length 105 but was 48. Strings differ at index 0.
        Expected: {Get-Item -Path 'C:\inetpub\wwwroot\iisstart.htm' -ErrorAction SilentlyContinue | should not benullore
mpty}
        But was:  {'C:\inetpub\wwwroot\iisstart.htm' | Should Exist}
        -----------^
        at <ScriptBlock>, C:\Users\Administrator\Documents\WindowsPowerShell\Modules\poshspec\2.1.16\Tests\poshspec.Test
s.ps1: line 297
        297:                 $results.Expression | Should Be "Get-Item -Path 'C:\inetpub\wwwroot\iisstart.htm' -ErrorAct
ion SilentlyContinue | should not benullorempty"

    Context Registry w/o Properties
      [+] Should return the correct test Name 35ms
      [-] Should return the correct test Expression 12ms
        Expected string length 118 but was 61. Strings differ at index 0.
        Expected: {Get-Item -Path 'HKLM:\SOFTWARE\Microsoft\Rpc\ClientProtocols' -ErrorAction SilentlyContinue | should
not benullorempty}
        But was:  {'HKLM:\SOFTWARE\Microsoft\Rpc\ClientProtocols' | Should Exist}
        -----------^
        at <ScriptBlock>, C:\Users\Administrator\Documents\WindowsPowerShell\Modules\poshspec\2.1.16\Tests\poshspec.Test
s.ps1: line 310
        310:                 $results.Expression | Should Be "Get-Item -Path 'HKLM:\SOFTWARE\Microsoft\Rpc\ClientProtoco
ls' -ErrorAction SilentlyContinue | should not benullorempty"

    Context Hotfix
      [+] Should return the correct test Name 33ms
      [-] Should return the correct test Expression 13ms
        Expected string length 81 but was 69. Strings differ at index 64.
        Expected: {Get-HotFix -Id KB1234567 -ErrorAction SilentlyContinue | should not benullorempty}
        But was:  {Get-HotFix -Id KB1234567 -ErrorAction SilentlyContinue | Should Exist}
        ---------------------------------------------------------------------------^
        at <ScriptBlock>, C:\Users\Administrator\Documents\WindowsPowerShell\Modules\poshspec\2.1.16\Tests\poshspec.Test
s.ps1: line 362
        362:                 $results.Expression | Should Be "Get-HotFix -Id KB1234567 -ErrorAction SilentlyContinue | s
hould not benullorempty"

    Context Folder
      [+] Should return the correct test Name 33ms
      [-] Should return the correct test Expression 13ms
        Expected string length 88 but was 31. Strings differ at index 0.
        Expected: {Get-Item -Path 'C:\ProgramData' -ErrorAction SilentlyContinue | should not benullorempty}
        But was:  {'C:\ProgramData' | should exist}
        -----------^
        at <ScriptBlock>, C:\Users\Administrator\Documents\WindowsPowerShell\Modules\poshspec\2.1.16\Tests\poshspec.Test
s.ps1: line 488
        488:                 $results.Expression | Should Be "Get-Item -Path 'C:\ProgramData' -ErrorAction SilentlyConti
nue | should not benullorempty"

    Context SoftwareProduct
      [+] Should return the correct test Name 34ms
      [-] Should return the correct test Expression 13ms
        Expected string length 270 but was 165. Strings differ at index 0.
        Expected: {@('HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\\Software\Microsof
t\Windows\CurrentVersion\Uninstall\*') | Where-Object { Test-Path  } | Get-ItemProperty | Where-Object DisplayName -Matc
h 'Microsoft .NET Framework 4.6.1' | Should Exist}
        But was:  {Get-ItemProperty -Path hklm:\\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object Di
splayName -Match 'Microsoft .NET Framework 4.6.1' | Should Exist}
        -----------^
        at <ScriptBlock>, C:\Users\Administrator\Documents\WindowsPowerShell\Modules\poshspec\2.1.16\Tests\poshspec.Test
s.ps1: line 583
        583:                 $results.Expression | Should Be "@('HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVer
sion\Uninstall\*','HKLM:\\Software\Microsoft\Windows\CurrentVersion\Uninstall\*') | Where-Object { Test-Path $_ } | Get-
ItemProperty | Where-Object DisplayName -Match 'Microsoft .NET Framework 4.6.1' | Should Exist"

    Context SoftwareProduct w/Property
      [+] Should return the correct test Name 41ms
      [-] Should return the correct test Expression 10ms
        Expected string length 326 but was 221. Strings differ at index 0.
        Expected: {@('HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\\Software\Microsof
t\Windows\CurrentVersion\Uninstall\*') | Where-Object { Test-Path  } | Get-ItemProperty | Where-Object DisplayName -Matc
h 'Microsoft .NET Framework 4.6.1' | Select-Object -ExpandProperty 'DisplayVersion' | Should Be 4.6.01055}
        But was:  {Get-ItemProperty -Path hklm:\\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object Di
splayName -Match 'Microsoft .NET Framework 4.6.1' | Select-Object -ExpandProperty 'DisplayVersion' | Should Be 4.6.01055
}
        -----------^
        at <ScriptBlock>, C:\Users\Administrator\Documents\WindowsPowerShell\Modules\poshspec\2.1.16\Tests\poshspec.Test
s.ps1: line 596
        596:                 $results.Expression | Should Be "@('HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVer
sion\Uninstall\*','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 'Display
Version' | Should Be 4.6.01055"
jgigler commented 7 years ago

PR #49 and PR #50 resolve this.