From a8d8ccc061a3fb2f6f6edb3b119f45df03d90034 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 19:26:11 +0100 Subject: [PATCH] test --- tests/tests_jc2server.sh | 52 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 86c88537f..d02130883 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -14,6 +14,30 @@ githubuser="dgibbs64" githubrepo="linuxgsm" githubbranch="$TRAVIS_BRANCH" +# 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" + exitcode=1 + core_exit.sh + else + fn_print_ok "Test Pass" + fi +} + +# if excpecting a fail +fn_test_result_fail(){ + if [ $? == 0 ]; then + fn_print_fail "Test Failure" + exitcode=1 + core_exit.sh + else + fn_print_ok "Test Pass" + fi +} + echo "=================================" echo "TravisCI Tests" echo "Linux Game Server Manager" @@ -37,6 +61,32 @@ echo "Downloading jc2server" wget https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/JustCause2/jc2server chmod +x jc2server echo "Create log dir" -mkdir -p log/script/ +mkdir -pv log/script/ echo "Enable dev-debug" ./jc2server dev-debug + +echo "1.0 - start - no files" +echo "=================================" +echo "Description:" +echo "test script reaction to missing server files." +echo "" +./jc2server start +fn_test_result_fail + +echo "" +echo "1.1 - getopt" +echo "=================================" +echo "Description:" +echo "displaying options messages." +echo "" +./jc2server +fn_test_result_pass + +echo "" +echo "1.2 - getopt with incorrect args" +echo "=================================" +echo "Description:" +echo "displaying options messages." +echo "" +./jc2server +fn_test_result_fail \ No newline at end of file