blob: d02cb5da8e155214fcc6b841af574e6ce9a7cbe6 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
Victor Moralesdd074802017-07-26 16:06:35 -05005source /var/onap/commons
6
Victor Morales89ce3212017-06-16 18:32:48 -05007# asserts_image() - Function that verifies if a specific image was created
8function asserts_image {
Victor Moralesdd074802017-07-26 16:06:35 -05009 local image=$1
10 local error_msg=${2:-"There is no $image image"}
11
12 if [[ "$(docker images -q $image 2> /dev/null)" == "" ]]; then
13 raise_error $error_msg
Victor Morales89ce3212017-06-16 18:32:48 -050014 fi
15}
Victor Moralesdd074802017-07-26 16:06:35 -050016
17# asserts_installed_package() - Function that verifies if a specific package was installed.
18function asserts_installed_package {
19 local package=$1
20 local error_msg=${2:-"$package wasn't installed"}
21
22 if ! is_package_installed $package; then
23 raise_error $error_msg
24 fi
25}
26
27# asserts_file_exist() - Function that verifies if a specific file exists
28function asserts_file_exist {
29 local file=$1
30 local error_msg=${2:-"$file doesn't exist"}
31
32 if [ ! -f $file ]; then
33 raise_error $error_msg
34 fi
35}
36
37# raise_error() - Function that prints and exits the execution
38function raise_error {
39 echo $@
40 exit 1
41}