blob: 2fcd7dafd50c861999551df3883de901db377329 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/usr/bin/env bash
set -euo pipefail
export CHEF_LICENSE="accept-no-persist"
export HAB_LICENSE="accept-no-persist"
export HAB_NONINTERACTIVE="true"
project_root="$(git rev-parse --show-toplevel)"
pkg_ident="$1"
# 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}" chef-client -- --version | sed 's/.*: //')
[[ "$package_version" = "$actual_version" ]] || error "chef-client is not the expected version. Expected '$package_version', got '$actual_version'"
for executable in 'chef-client' 'ohai' 'chef-shell' 'chef-apply' 'knife' 'chef-solo'; do
echo -en "\t$executable = "
hab pkg exec "${pkg_ident}" "${executable}" -- --version || error "${executable} failed to execute properly"
done
echo "--- :mag_right: Testing ${pkg_ident} functionality"
hab pkg exec "${pkg_ident}" rspec -f documentation --tag ~executables spec/functional || error 'failures during rspec tests'
|