ticketmaster / poshspec

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

[Bug] Package function breaks when package name contains single quotes #20

Closed megamorf closed 5 years ago

megamorf commented 8 years ago

Hey guys,

I'd like to report the following error:

Describe 'Appsense is installed and configured' {
    Context 'Appsense Agents are installed' {
        Package "AppSense Application Manager Agent 8.9 SP1" Version { Should Be '8.9.451.0' }
        Package "AppSense Application Manager Configuration 'xzy-Desktop' 8.9.18.0" Version { Should Be '8.9.18.0' }
    }
}

The first package function call works while the second doesn't recognize the name parameter properly:

[-] Package property 'Version' for 'AppSense Application Manager Configuration 'xyz-Desktop' 8.3.0.0' Should Be '8.3.0.0' 67ms
  ParameterBindingException: A positional parameter cannot be found that accepts argument "xyz-Desktop 8.3.0.0".
  at <ScriptBlock>, <No file>: Line 1
  at <ScriptBlock>, C:\Program Files\WindowsPowerShell\Modules\poshspec\2.1.12\Private\Invoke-PoshspecExpression.ps1: Line 12
  at Invoke-Test, C:\Program Files\WindowsPowerShell\Modules\pester\3.4.1\Functions\It.ps1: Line 253
  at ItImpl, C:\Program Files\WindowsPowerShell\Modules\pester\3.4.1\Functions\It.ps1: Line 203
  at It, C:\Program Files\WindowsPowerShell\Modules\pester\3.4.1\Functions\It.ps1: Line 117
  at Invoke-PoshspecExpression, C:\Program Files\WindowsPowerShell\Modules\poshspec\2.1.12\Private\Invoke-PoshspecExpression.ps1: Line 11
  at Package, C:\Program Files\WindowsPowerShell\Modules\poshspec\2.1.12\Public\Package.ps1: Line 42
  at <ScriptBlock>, \\fileserver\citrix$\citrix-scripts\OperationalValidation\WTS\Tests\Diagnostics\Simple\02-Citrix\Appsense.Tests.ps1: Line 9
  at Context, C:\Program Files\WindowsPowerShell\Modules\pester\3.4.1\Functions\Context.ps1: Line 66
  at <ScriptBlock>, \\fileserver\citrix$\citrix-scripts\OperationalValidation\WTS\Tests\Diagnostics\Simple\02-Citrix\Appsense.Tests.ps1: Line 2
  at Describe, C:\Program Files\WindowsPowerShell\Modules\pester\3.4.1\Functions\Describe.ps1: Line 103
  at <ScriptBlock>, \\fileserver\citrix$\citrix-scripts\OperationalValidation\WTS\Tests\Diagnostics\Simple\02-Citrix\Appsense.Tests.ps1: Line 1

The package can be found with the Get-Package cmdlet:

PS C:\> Get-Package -Name "AppSense Application Manager Configuration 'xyz-Desktop' 8.9.18.0"

Name                           Version          Source                         Summary                                                                                                                      
----                           -------          ------                         -------                                                                                                                      
AppSense Application Manage... 8.9.18.0         C:\Program Files\AppSense\M...                                                                                                                     

I guess this is an internal quotation handling problem.

cdhunt commented 8 years ago

I've built a release that includes the PRs related to Package. I haven't done any functional testing on it myself, yet.

https://github.com/Ticketmaster/poshspec/releases/tag/v2.1.14-pre

megamorf commented 8 years ago

The fix works for me. 👍