Browse Source

whole tests batch now are ordered to add, then update, and finally delete a test line

nas 3 years ago
parent
commit
0a9f8559c1

+ 2
- 0
test/.gitignore View File

@@ -0,0 +1,2 @@
1
+*~
2
+cookie.txt

test/post_line.sh → test/alter_table.sh View File

@@ -1,4 +1,4 @@
1
-#/bin/sh
1
+#!/bin/sh
2 2
 
3 3
 help() {
4 4
     echo "Syntaxe"
@@ -24,8 +24,6 @@ fi
24 24
 . ./dep/tablename.sh
25 25
 . ./dep/data.sh
26 26
 
27
-. ./tools/title.sh
28
-echo "Post $data to table $tablename"
29
-result=`curl --header "Content-Type: application/json" -b cookie.txt -X POST --data ’$data’ $address/api.php/records/$tablename/ 2>/dev/null`
30
-sh tools/show_result.sh $result
31
-echo "\n"
27
+. ./tools/post_line.sh
28
+. ./tools/set_line.sh
29
+. ./tools/del_line.sh

+ 0
- 31
test/del_line.sh View File

@@ -1,31 +0,0 @@
1
-#/bin/sh
2
-
3
-help() {
4
-    echo "Syntaxe"
5
-    echo "‾‾‾‾‾‾‾"
6
-    echo "sh $0 [ adresse ] [ tablename ] [ id ]\n"
7
-}
8
-
9
-if [ "$1" ]
10
-then
11
-    address=$1
12
-fi
13
-if [ "$2" ]
14
-then
15
-    tablename=$2
16
-fi
17
-if [ "$3" ]
18
-then
19
-    id=$3
20
-fi
21
-
22
-. ./config.sh
23
-. ./dep/address.sh
24
-. ./dep/tablename.sh
25
-. ./dep/id.sh
26
-
27
-. ./tools/title.sh
28
-echo "Delete id $3 of table $2"
29
-result=`curl --header "Content-Type: application/json" -X "DELETE" -b cookie.txt $address/api.php/records/$tablename/$id 2> /dev/null`
30
-sh tools/show_result.sh $result
31
-echo "\n"

+ 0
- 30
test/list_users.sh View File

@@ -1,30 +0,0 @@
1
-#/bin/sh
2
-
3
-help() {
4
-    echo "Syntaxe"
5
-    echo "‾‾‾‾‾‾‾"
6
-    echo "sh $0 [ adresse ] [ username ] [ password ]\n"
7
-}
8
-
9
-if [ -z "$1" ]
10
-then
11
-    echo "Missing parameters : web adresses is needed\n"
12
-    help
13
-    exit
14
-fi
15
-if [ -z "$2" ]
16
-then
17
-    echo "Missing parameters : username is needed\n"
18
-    help
19
-    exit
20
-fi
21
-if [ -z "$3" ]
22
-then
23
-    echo "Missing parameters : password is needed\n"
24
-    help
25
-    exit
26
-fi
27
-echo "Login as $2 in cookie.txt"
28
-echo "$1 $2 $3"
29
-curl --header "Content-Type: application/json" --cookie-jar cookie.txt --request POST --data "{\"username\":\"$2\",\"password\":\"$3\"}" $1/api.php/login
30
-echo "\n"

+ 0
- 38
test/set_line.sh View File

@@ -1,38 +0,0 @@
1
-#/bin/sh
2
-
3
-help() {
4
-    echo "Syntaxe"
5
-    echo "‾‾‾‾‾‾‾"
6
-    echo "sh $0 [ adresse ] [ table ] [ id ] [ data ]\n"
7
-}
8
-
9
-if [ "$1" ]
10
-then
11
-    address=$1
12
-
13
-fi
14
-if [ "$2" ]
15
-then
16
-    tablename=$2
17
-fi
18
-
19
-if [ "$3" ]
20
-then
21
-    id=$3
22
-fi
23
-if [ "$4" ]
24
-then
25
-    data=$4
26
-fi
27
-
28
-. ./config.sh
29
-. ./dep/address.sh
30
-. ./dep/tablename.sh
31
-. ./dep/id.sh
32
-. ./dep/data.sh
33
-
34
-. ./tools/title.sh
35
-echo "Set data for tablename with id $id"
36
-result=`curl --header "Content-Type: application/json" -b cookie.txt -X PUT --data "$data" $address/api.php/records/$tablename/$id 2>/dev/null`
37
-sh tools/show_result.sh $result
38
-echo "\n"

+ 1
- 1
test/test.conf View File

@@ -3,4 +3,4 @@ password=starwars
3 3
 address=192.168.1.152:8080
4 4
 tablename=ticket
5 5
 id=1
6
-data=’{"name" : "ondoing test run", "description" : "this ticket has been added by a testscript"}’
6
+data="{\"name\" : \"ondoing test run\", \"description\" : \"this ticket has been added by a testscript\"}"

+ 7
- 0
test/tools/del_line.sh View File

@@ -0,0 +1,7 @@
1
+#/bin/sh
2
+
3
+. ./tools/title.sh
4
+echo "Delete id $id of table $tablename"
5
+result=`curl -X "DELETE" -b cookie.txt $address/api.php/records/$tablename/$id 2> /dev/null`
6
+. ./tools/show_result.sh
7
+echo "\n"

+ 14
- 0
test/tools/get_result.sh View File

@@ -0,0 +1,14 @@
1
+#!/bin/sh
2
+
3
+code=`echo $result | grep code`
4
+
5
+if [ $code ]
6
+then
7
+    echo "\e[1;31mTest : [fail]\e[0m"
8
+else
9
+    echo "\e[1;32mResult [success]\e[0m"
10
+    return $0
11
+fi
12
+
13
+
14
+

+ 9
- 0
test/tools/post_line.sh View File

@@ -0,0 +1,9 @@
1
+#/bin/sh
2
+
3
+. ./tools/title.sh
4
+echo "Post $data to table $tablename"
5
+result=`curl --header "Content-Type: application/json" -b cookie.txt -X POST --data "$data" $address/api.php/records/$tablename/ 2>/dev/null`
6
+id=$result
7
+. ./tools/show_result.sh
8
+echo "\n"
9
+

+ 8
- 0
test/tools/set_line.sh View File

@@ -0,0 +1,8 @@
1
+#/bin/sh
2
+
3
+. ./tools/title.sh
4
+echo ’Set data $data for tablename $tablename with id $id’
5
+result=`curl --header "Content-Type: application/json" -b cookie.txt -X PUT --data "$data" $address/api.php/records/$tablename/$id 2>/dev/null`
6
+. ./tools/show_result.sh
7
+echo "\n"
8
+

+ 3
- 2
test/tools/show_result.sh View File

@@ -1,12 +1,13 @@
1 1
 #!/bin/sh
2 2
 
3 3
 code=`echo $1 | grep code`
4
-
5 4
 if [ $code ]
6 5
 then
7 6
     echo "\e[1;31mTest : [fail]\e[0m"
8 7
 else
9
-    echo "\e[1;32mResult [success]\e[0m"
8
+   echo "\e[1;32mResult [success]\e[0m"
10 9
 fi
11 10
 
12 11
 
12
+
13
+

Loading…
Cancel
Save