aboutsummaryrefslogtreecommitdiffstats
path: root/tests/03_delete
blob: 6cc0dbc9ae8faa454cce1f5116b4129281f6fc66 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash

init delete

# setup test configs
path1=$BIN/test1.conf
path2=$BIN/test2.conf
path3=$BIN/test3.conf
path4=$BIN/test4.conf

add_config prog1 $path1
add_config prog1 $path2

add_config prog2 $path3
add_config prog2 $path4

# delete path1
exec $BIN/ck conf $BIN del -c $path1 > /dev/null &
wait $!

for i in $($BIN/ck conf $BIN list paths); do
    if [[ "$i" == "$path1" ]]; then
       echo -e $ERROR" Couldn't delete path."
       exit 1
    fi
done

# delete path2 (also prog1)
exec $BIN/ck conf $BIN del -c $path2 > /dev/null &
wait $!

for i in $($BIN/ck conf $BIN list programs); do
    if [[ "$i" == "prog1" ]]; then
       echo -e $ERROR" Removing all configs should delete the correspondig program."
       exit 1
    fi
done

# delete prog2
exec $BIN/ck conf $BIN del prog2 > /dev/null &
wait $!

for i in $($BIN/ck conf $BIN list paths); do
    if [[ "$i" == "$path3" ]] || [[ "$i" == "$path4" ]]; then
       echo -e $ERROR" Removing the program should delete all it's configs."
       exit 1
    fi
done

for i in $($BIN/ck conf $BIN list programs); do
    if [[ "$i" == "prog1" ]]; then
       echo -e $ERROR" Couldn't remove program."
       exit 1
    fi
done

clear_tests
echo -e $PASS