summaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/lib/asserts
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap/vagrant-onap/lib/asserts')
-rwxr-xr-xbootstrap/vagrant-onap/lib/asserts36
1 files changed, 33 insertions, 3 deletions
diff --git a/bootstrap/vagrant-onap/lib/asserts b/bootstrap/vagrant-onap/lib/asserts
index 0e455382a..d02cb5da8 100755
--- a/bootstrap/vagrant-onap/lib/asserts
+++ b/bootstrap/vagrant-onap/lib/asserts
@@ -2,10 +2,40 @@
set -o xtrace
+source /var/onap/commons
+
# asserts_image() - Function that verifies if a specific image was created
function asserts_image {
- if [[ "$(docker images -q $1 2> /dev/null)" == "" ]]; then
- echo "There is no $1 image"
- exit 1
+ local image=$1
+ local error_msg=${2:-"There is no $image image"}
+
+ if [[ "$(docker images -q $image 2> /dev/null)" == "" ]]; then
+ raise_error $error_msg
+ fi
+}
+
+# asserts_installed_package() - Function that verifies if a specific package was installed.
+function asserts_installed_package {
+ local package=$1
+ local error_msg=${2:-"$package wasn't installed"}
+
+ if ! is_package_installed $package; then
+ raise_error $error_msg
fi
}
+
+# asserts_file_exist() - Function that verifies if a specific file exists
+function asserts_file_exist {
+ local file=$1
+ local error_msg=${2:-"$file doesn't exist"}
+
+ if [ ! -f $file ]; then
+ raise_error $error_msg
+ fi
+}
+
+# raise_error() - Function that prints and exits the execution
+function raise_error {
+ echo $@
+ exit 1
+}