aboutsummaryrefslogblamecommitdiffstats
path: root/tests/add
blob: 77ff7591864b9bf840f9383c5353be6ecdbb90bf (plain) (tree)
1
2
3
4
5
6
7
8
9
           
 
        





                               


































                                                                                                        
             
#!/bin/bash

init add

# setup test configs
echo "Test 1" > $BIN/test1.conf
echo "Test 2" > $BIN/test2.conf
echo "Test 3" > $BIN/test3.conf

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