From 4eb3a3dcd1108ae8d441c980eae4230e46a19fa9 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Thu, 28 Jun 2018 20:44:07 -0500 Subject: [PATCH] test: Add test update-repository-version.sh Add some basic test to verify the script works. Signed-off-by: Jose Carlos Venegas Munoz --- Makefile | 1 + release/update-repository-version_test.sh | 54 +++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 release/update-repository-version_test.sh diff --git a/Makefile b/Makefile index 14308d14e9..73ba5f7d98 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ test: test-release-tools: @$(MK_DIR)/release/tag_repos_test.sh + @$(MK_DIR)/release/update-repository-version_test.sh test-static-build: @make -f $(MK_DIR)/static-build/qemu/Makefile diff --git a/release/update-repository-version_test.sh b/release/update-repository-version_test.sh new file mode 100755 index 0000000000..590a5d0e57 --- /dev/null +++ b/release/update-repository-version_test.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +#Copyright (c) 2018 Intel Corporation +# +#SPDX-License-Identifier: Apache-2.0 +# + +set -o errexit +set -o nounset +set -o pipefail + +readonly script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +out="" + +handle_error(){ + echo "not ok" + echo "output: ${out}" +} + +OK(){ + echo "ok" +} +output_should_contain(){ + local output="$1" + local text_to_find="$2" + [ -n "$output" ] + [ -n "$text_to_find" ] + echo "${output}" | grep "${text_to_find}" +} + +trap handle_error ERR + +echo "Missing args show help" +out=$("${script_dir}/update-repository-version.sh" 2>&1) || (($?!=0)) +echo "${out}" | grep Usage >> /dev/null +output_should_contain "${out}" "Usage" +OK + +echo "Missing version show help" +out=$("${script_dir}/update-repository-version.sh" runtime 2>&1) || (($?!=0)) +echo "${out}" | grep Usage >> /dev/null +echo "${out}" | grep "no new version">> /dev/null +OK + +echo "help option" +out=$("${script_dir}/update-repository-version.sh" -h) +output_should_contain "${out}" "Usage" +OK + +echo "Local update version update should work" +new_version=50.0.0 +out=$("${script_dir}/update-repository-version.sh" runtime ${new_version} 2>&1) +output_should_contain "${out}" "release: Kata Containers ${new_version}" +OK