From 1fcb075383a0b30fa69f3e535be9bde704252fe0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 19:32:37 +0100 Subject: [PATCH] test --- tests/tests_jc2server.sh | 79 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 5 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index d02130883..d62c8e50e 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -14,27 +14,89 @@ githubuser="dgibbs64" githubrepo="linuxgsm" githubbranch="$TRAVIS_BRANCH" +##### Script ##### + +# Fetches core_dl for file downloads +fn_fetch_core_dl(){ +github_file_url_dir="lgsm/functions" +github_file_url_name="${functionfile}" +filedir="${functionsdir}" +filename="${github_file_url_name}" +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +# If the file is missing, then download +if [ ! -f "${filedir}/${filename}" ]; then + if [ ! -d "${filedir}" ]; then + mkdir -p "${filedir}" + fi + echo -e " fetching ${filename}...\c" + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) + if [ $? -ne 0 ]; then + echo -e "\e[0;31mFAIL\e[0m\n" + echo "${curlfetch}" + echo -e "${githuburl}\n" + exit 1 + else + echo -e "\e[0;32mOK\e[0m" + fi + else + echo -e "\e[0;31mFAIL\e[0m\n" + echo "Curl is not installed!" + echo -e "" + exit 1 + fi + chmod +x "${filedir}/${filename}" +fi +source "${filedir}/${filename}" +} + +core_dl.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl +} + +core_functions.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl +} + +core_dl.sh +core_functions.sh + + + # End of every test will expect the result to either pass or fail # If the script does not do as intended the whole test will fail # if excpecting a pass fn_test_result_pass(){ if [ $? != 0 ]; then - fn_print_fail "Test Failure" + fn_print_fail "Test Failed" exitcode=1 core_exit.sh else - fn_print_ok "Test Pass" + fn_print_ok "Test Passed" fi } # if excpecting a fail fn_test_result_fail(){ if [ $? == 0 ]; then - fn_print_fail "Test Failure" + fn_print_fail "Test Failed" exitcode=1 core_exit.sh else - fn_print_ok "Test Pass" + fn_print_ok "Test Passed" fi } @@ -89,4 +151,11 @@ echo "Description:" echo "displaying options messages." echo "" ./jc2server -fn_test_result_fail \ No newline at end of file +fn_test_result_fail + +echo "2.0 - install" +echo "=================================" +echo "Description:" +echo "install Just Cause 2 server." +./jc2server auto-install +fn_test_result_pass \ No newline at end of file