Skip to content

Commit

Permalink
add version check in hab environment
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin <[email protected]>
  • Loading branch information
Sachin committed Dec 3, 2024
1 parent 7e6fe7a commit b1dc5fb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
15 changes: 15 additions & 0 deletions habitat/tests/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Write-Host "--- :fire: Smokish test"
# Pester the Package
$version=hab pkg exec "${pkg_ident}" berks -v
$actual_version=[Regex]::Match($version,"([0-9]+.[0-9]+.[0-9]+)").Value
$package_version=$PackageIdentifier.split("/",4)[2]

Write-Host "package_version $package_version actual version $actual_version"
if ($package_version -eq $actual_version)
{
Write "Berkshelf working fine"
}
else {
Write-Error "Berkshelf version not met expected $package_version actual version $actual_version "
throw "Berkshelf windows pipeline not working for hab pkg"
}
23 changes: 23 additions & 0 deletions habitat/tests/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set -euo pipefail


project_root="$(git rev-parse --show-toplevel)"

# print error message followed by usage and exit
error () {
local message="$1"

echo -e "\nERROR: ${message}\n" >&2

exit 1
}

[[ -n "$pkg_ident" ]] || error 'no hab package identity provided'

package_version=$(awk -F / '{print $3}' <<<"$pkg_ident")

cd "${project_root}"

echo "--- :mag_right: Testing ${pkg_ident} executables"
actual_version=$(hab pkg exec "${pkg_ident}" berks -v | sed -E 's/.*: ([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
[[ "$package_version" = "$actual_version" ]] || error "Berkshelf version is not the expected version. Expected '$package_version', got '$actual_version'"

0 comments on commit b1dc5fb

Please sign in to comment.