diff --git a/habitat/tests/test.pester.ps1 b/habitat/tests/test.pester.ps1 deleted file mode 100644 index 4ffdd762..00000000 --- a/habitat/tests/test.pester.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -param( - [Parameter()] - [string]$PackageIdentifier = $(throw "Usage: test.ps1 [test_pkg_ident] e.g. test.ps1 ci/user-windows-default/1.0.0/20190812103929") -) - -$PackageVersion = $PackageIdentifier.split('/')[2] - -Describe "chef-cli" { - Context "chef-cli" { - It "is an executable" { - hab pkg exec $PackageIdentifier chef-cli.bat --version - $? | Should be $true - } - - <# - At some point hab's argument parsing changed and it started interpreting the trailing `--version` as being - an argument passed to hab instead of an argument to the command passed to `hab pkg exec`. - - Powershell 5.1 and 7 appear to differ in how they treat following arguments as well, such that these two - versions of the command fail in powershell 5.1 (which is currently what is running in the windows machines - in Buildkite) but pass in powershell 7 (which is currently what is running in a stock Windows 10 VM). - - $the_version = (hab pkg exec $PackageIdentifier chef-client.bat '--version' | Out-String).split(':')[1].Trim() - $the_version = (hab pkg exec $PackageIdentifier chef-client.bat --version | Out-String).split(':')[1].Trim() - - This version of the command passes in powershell 5.1 but fails in powershell 7. - #> - It "is the expected version" { - $the_version = (hab pkg exec $PackageIdentifier chef-cli.bat -- --version | Out-String).split(':')[1].Trim() - $the_version | Should be $PackageVersion - } - } -} diff --git a/habitat/tests/test.ps1 b/habitat/tests/test.ps1 index a0df7c70..31897373 100644 --- a/habitat/tests/test.ps1 +++ b/habitat/tests/test.ps1 @@ -11,9 +11,13 @@ if (-Not (Get-Module -ListAvailable -Name Pester)){ Write-Host "--- :fire: Smokish Pestering" # Pester the Package -$__dir=(Get-Item $PSScriptRoot) -$test_result = Invoke-Pester -Strict -PassThru -Script @{ - Path = "habitat/tests/test.pester.ps1"; - Parameters = @{PackageIdentifier=$PackageIdentifier} +$version=hab pkg exec "${pkg_ident}" chef-cli -v +$actual_version=[Regex]::Match($version,"([0-9]+.[0-9]+.[0-9]+)").Value +$package_version=$PackageIdentifier.split("/",4)[2] +if ($package_version -eq $actual_version) +{ + Write "Chef-cli working fine" } -if ($test_result.FailedCount -ne 0) { Exit $test_result.FailedCount } +else { + Write-Error "chef-cli version not met expected $package_version actual version $actual_version " +} \ No newline at end of file