diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-04-30 12:48:13 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-04-30 12:48:13 +0300 |
commit | b9c36055e855163e5bf2fc065d8f7ee7b9efa64c (patch) | |
tree | e06a1eb4e7c8c6dbc59f334d3615c7bac3145f44 /tests/add | |
parent | 584a9b642a689b6dccc5c66a518b9fc91a6fa733 (diff) | |
download | ck-b9c36055e855163e5bf2fc065d8f7ee7b9efa64c.tar.gz ck-b9c36055e855163e5bf2fc065d8f7ee7b9efa64c.tar.bz2 ck-b9c36055e855163e5bf2fc065d8f7ee7b9efa64c.zip |
Update tests
Diffstat (limited to 'tests/add')
-rw-r--r-- | tests/add | 108 |
1 files changed, 36 insertions, 72 deletions
@@ -1,81 +1,45 @@ #!/bin/bash -BIN=@CMAKE_BINARY_DIR@ -# initialize -TEST_LOCATION=@PROJECT_TESTING_GROUNDS@ -mkdir -p $TEST_LOCATION/vc -mkdir $TEST_LOCATION/sec - -exec $BIN/ck conf $BIN init $TEST_LOCATION/vc $TEST_LOCATION/sec & -wait $! +init add # setup test configs echo "Test 1" > $BIN/test1.conf echo "Test 2" > $BIN/test2.conf echo "Test 3" > $BIN/test3.conf -# add configs to ck -exec $BIN/ck conf $BIN add prog1 $BIN/test1.conf -p & -wait $! - -# check db -if [ $(sqlite3 $BIN/ckdb "select name from program where name = 'prog1'" | wc -l) -ne 1 ]; then - echo -e $ERROR"prog1 is not in the db" - exit 1 -fi - -if [ $(sqlite3 $BIN/ckdb "select path from config where path = '"$BIN"/test1.conf'" | wc -l) -ne 1 ]; then - echo -e $ERROR"test1.conf is not in the db" - exit 1 -fi - -# check files -if [ ! -f $TEST_LOCATION/vc/prog1_test1.conf ]; then - echo -e $ERROR"test1.conf failed (add -p)" - exit 1 -fi - -# repeat -exec $BIN/ck conf $BIN add prog2 $BIN/test2.conf -s & -wait $! - -if [ ! -f $TEST_LOCATION/sec/prog2_test2.conf ]; then - echo -e $ERROR"test2.conf failed (add -s)" - exit 1 -fi - -if [ $(sqlite3 $BIN/ckdb "select name from program where name = 'prog2'" | wc -l) -ne 1 ]; then - echo -e $ERROR"prog2 is not in the db" - exit 1 -fi - -if [ $(sqlite3 $BIN/ckdb "select path from config where path = '"$BIN"/test2.conf'" | wc -l) -ne 1 ]; then - echo -e $ERROR"test2.conf is not in the db" - exit 1 -fi - -exec $BIN/ck conf $BIN add prog3 $BIN/test3.conf -p -s & -wait $! - -if [ ! -f $TEST_LOCATION/sec/prog3_test3.conf ]; then - echo -e $ERROR"test3.conf failed (add -p -s)" - exit 1 -fi - -if [ $(sqlite3 $BIN/ckdb "select name from program where name = 'prog3'" | wc -l) -ne 1 ]; then - echo -e $ERROR"prog3 is not in the db" - exit 1 -fi - -if [ $(sqlite3 $BIN/ckdb "select path from config where path = '"$BIN"/test3.conf'" | wc -l) -ne 1 ]; then - echo -e $ERROR"test3.conf is not in the db" - exit 1 -fi - -rm $BIN/ckrc -rm $BIN/ckdb -rm $BIN/test1.conf -rm $BIN/test2.conf -rm $BIN/test3.conf -rm -rf $TEST_LOCATION +function run_add { + # add configs to ck + exec $BIN/ck conf $BIN add $1 $BIN/$2 $3 $4 & + wait $! + + # check db + if [ $(sqlite3 $BIN/ckdb "select name from program where name = '"$1"'" | wc -l) -ne 1 ]; then + echo -e $ERROR$1" is not in the db" + exit 1 + fi + + if [ $(sqlite3 $BIN/ckdb "select path from config where path = '"$BIN"/"$2"'" | wc -l) -ne 1 ]; then + echo -e $ERROR$2" is not in the db" + exit 1 + fi + + FOLDER=vc + + # check files + if [[ "$3" = "-s" || "$4" = "-s" ]]; then + FOLDER=sec + fi + + if [ ! -f $TEST_LOCATION/$FOLDER/$1_$2 ]; then + echo -e $ERROR$2" failed (add "$3" "$4")" + exit 1 + fi +} + +run_add prog1 test1.conf -p +run_add prog2 test2.conf -s +run_add prog3 test3.conf -p -s + + +clear_tests echo -e $PASS |