From 7d10e2377b01ac3e38b412f6bc2fa2e384804057 Mon Sep 17 00:00:00 2001 From: gramanas Date: Sun, 18 Nov 2018 20:58:35 +0200 Subject: Update edit and add edit test --- test/06_edit | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 test/06_edit (limited to 'test') diff --git a/test/06_edit b/test/06_edit new file mode 100644 index 0000000..65419b1 --- /dev/null +++ b/test/06_edit @@ -0,0 +1,83 @@ +#!/bin/bash + +init edit + +# add configs to ck +path1=$BIN/test1.conf +path2=$BIN/test2.conf +path3=$BIN/test3.conf +path4=$BIN/test4.conf +path5=$BIN/test5.conf + +add_config prog1 $path1 "" -p +add_config prog1 $path2 + +add_config prog2 $path3 +add_config prog2 $path4 + +add_config prog3 $path5 + +# edit primary +exec $BIN/ck -c $BIN e prog1 --command ":" > __test_file & +wait $! + +TEST_STR=$(cat __test_file) +EXPECTED_STR="Running: : $(realpath $path1)" + +echo "Expected: $EXPECTED_STR" >&${V} +echo " Actual: $TEST_STR" >&${V} + +if [[ "$TEST_STR" != "$EXPECTED_STR" ]]; then + err "Worng edit." + exit 1; +fi + +# edit specific +exec $BIN/ck -c $BIN e prog1 test2.conf --command ":" > __test_file & +wait $! + +echo "Expected: $EXPECTED_STR" >&${V} +echo " Actual: $TEST_STR" >&${V} + +TEST_STR=$(cat __test_file) +EXPECTED_STR="Running: : $(realpath $path2)" + +if [[ "$TEST_STR" != "$EXPECTED_STR" ]]; then + err "Worng edit." + exit 1; +fi + +# Ambiguous config +exec $BIN/ck -c $BIN e prog2 --command ":" > __test_file & +wait $! + +echo "Expected: $EXPECTED_STR" >&${V} +echo " Actual: $TEST_STR" >&${V} + +TEST_STR=$(head -1 __test_file) +EXPECTED_STR="Ambiguous config. Please type the config name after the program." + +if [[ "$TEST_STR" != "$EXPECTED_STR" ]]; then + err "Worng edit." + exit 1; +fi + +# solo program +exec $BIN/ck -c $BIN e prog3 --command ":" > __test_file & +wait $! + +echo "Expected: $EXPECTED_STR" >&${V} +echo " Actual: $TEST_STR" >&${V} + +TEST_STR=$(cat __test_file) +EXPECTED_STR="Running: : $(realpath $path5)" + +if [[ "$TEST_STR" != "$EXPECTED_STR" ]]; then + err "Worng edit." + exit 1; +fi + +rm __test_file + +clear_tests +echo -e $PASS -- cgit v1.2.3