Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -o xtrace |
| 4 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 5 | source /var/onap/commons |
| 6 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 7 | # asserts_image() - Function that verifies if a specific image was created |
| 8 | function asserts_image { |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 9 | 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 Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 14 | fi |
| 15 | } |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 16 | |
| 17 | # asserts_installed_package() - Function that verifies if a specific package was installed. |
| 18 | function 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 |
| 28 | function 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 |
| 38 | function raise_error { |
| 39 | echo $@ |
| 40 | exit 1 |
| 41 | } |