finishes dav put tests

Sun, 17 Jun 2018 07:49:25 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 17 Jun 2018 07:49:25 +0200
changeset 422
1429fb385513
parent 421
178dc32c8c9a
child 423
84e6c407b431

finishes dav put tests

test/bin-test/test-dav-put.sh file | annotate | diff | comparison | revisions
test/bin-test/test-dav.sh file | annotate | diff | comparison | revisions
test/bin-test/testdir/file1 file | annotate | diff | comparison | revisions
test/bin-test/testdir/file2 file | annotate | diff | comparison | revisions
test/bin-test/testdir/file3 file | annotate | diff | comparison | revisions
test/bin-test/testdir/subdir/sub1 file | annotate | diff | comparison | revisions
test/bin-test/testdir/subdir/sub2 file | annotate | diff | comparison | revisions
--- a/test/bin-test/test-dav-put.sh	Sun Jun 17 07:11:31 2018 +0200
+++ b/test/bin-test/test-dav-put.sh	Sun Jun 17 07:49:25 2018 +0200
@@ -35,11 +35,13 @@
 
 BASE_URL=`dav repo-url dav-test-repo`
 
-# test
+#
+# test simple file upload
+#
 echo "hello world" > hello
 dav put dav-test-repo/tests/ hello
 DAV_RES=$?
-rm hello
+rm -f hello
 
 if [ $DAV_RES -ne 0 ]; then
 	echo "dav put returned" $DAV_RES
@@ -59,4 +61,133 @@
 	exit 2
 fi
 
+echo "hello world" > hello
+curl --silent -o cmphello $BASE_URL/tests/hello
+diff hello cmphello > /dev/null
+RES=$?
+rm -f hello
+rm -f cmphello
+if [ $RES -ne 0 ]; then
+	echo "wrong content"
+	exit 2
+fi
 
+#
+# test dir upload
+#
+dav put -R dav-test-repo/tests/ testdir > /dev/null
+if [ $? -ne 0 ]; then
+	echo "dir upload failed"
+	exit 2
+fi
+
+# check file1
+curl --silent -o tmp_file1 $BASE_URL/tests/file1
+if [ $? -ne 0 ]; then
+	echo "cannot download file1"
+	rm -f tmp_file1
+	exit 2
+fi
+
+diff testdir/file1 tmp_file1 > /dev/null
+if [ $? -ne 0 ]; then
+	echo "file1 has wrong content"
+	rm -f tmp_file1
+	exit 2
+fi
+rm tmp_file1
+
+# check subdir file
+curl --silent -o tmp_sub1 $BASE_URL/tests/subdir/sub1
+if [ $? -ne 0 ]; then
+	echo "cannot download subdir/sub1"
+	rm tmp_sub1
+	exit 2
+fi
+
+diff testdir/subdir/sub1 tmp_sub1 > /dev/null
+if [ $? -ne 0 ]; then
+	echo "subdir/sub1 has wrong content"
+	rm -f tmp_sub1
+	exit 2
+fi
+rm -f tmp_sub1
+
+# check subdir
+OUT=`dav info dav-test-repo/tests/subdir`
+if [ $? -ne 0 ]; then
+	echo "cannot get subdir infos"
+	exit 2
+fi
+
+echo $OUT | grep "type: collection" > /dev/null
+if [ $? -ne 0 ];
+then
+	echo "subdir has wrong type"
+	exit 2
+fi
+
+#
+# test upload to specific url
+#
+dav put dav-test-repo/tests/uploaded_file testdir/file1
+if [ $? -ne 0 ]; then
+	echo "upload to /tests/uploaded_file failed"
+	exit 2
+fi
+curl --silent -o /dev/null $BASE_URL/tests/uploaded_file
+if [ $? -ne 0 ]; then
+	echo "uploaded_file has wrong content"
+	exit 2
+fi
+
+#
+# test upload with automatic collection creation
+#
+dav put dav-test-repo/tests/newdir/newsubdir/newfile testdir/file2
+if [ $? -ne 0 ]; then
+	echo "upload to /tests/newdir/newsubdir/newfile failed"
+	exit 2
+fi
+curl --silent -o /dev/null $BASE_URL/tests/newdir/newsubdir/newfile
+if [ $? -ne 0 ]; then
+	echo "newfile has wrong content"
+	exit 2
+fi
+
+#
+# test dir upload to specific url
+#
+dav put -R dav-test-repo/tests/testdir testdir > /dev/null
+if [ $? -ne 0 ]; then
+	echo "dir upload to /tests/testdir failed"
+	exit 2
+fi
+
+OUT=`dav info dav-test-repo/tests/testdir`
+if [ $? -ne 0 ]; then
+	echo "cannot get /tests/testdir infos"
+	exit 2
+fi
+
+echo $OUT | grep "type: collection" > /dev/null
+if [ $? -ne 0 ];
+then
+	echo "/tests/testdir has wrong type"
+	exit 2
+fi
+
+curl --silent -o tmp_file3 $BASE_URL/tests/testdir/file3
+CURL_RES=$?
+diff tmp_file3 testdir/file3 > /dev/null
+DIFF_RES=$?
+rm -f tmp_file3
+
+if [ $CURL_RES -ne 0 ]; then
+	echo "cannot download /tests/testdir/file3"
+	exit 2
+fi
+if [ $DIFF_RES -ne 0 ]; then
+	echo "/tests/testdir/file3 has wrong content"
+	exit 2
+fi
--- a/test/bin-test/test-dav.sh	Sun Jun 17 07:11:31 2018 +0200
+++ b/test/bin-test/test-dav.sh	Sun Jun 17 07:49:25 2018 +0200
@@ -51,7 +51,15 @@
 	exit 1
 fi
 
-
+do_test()
+{
+	printf "TEST: $1 ... "
+	./$2
+	if [ $? -ne 0 ]; then
+		exit 2
+	fi
+	echo ok
+}
 
 # clean test repo
 $DAV_BIN rm dav-test-repo/tests/ 2> /dev/null
@@ -60,26 +68,7 @@
 # ok, begin the tests
 #
 
-# info
-printf "TEST: dav info ... "
-./test-dav-info.sh
-if [ $? -ne 0 ]; then
-	exit 2
-fi
-echo ok
+do_test "dav info" test-dav-info.sh
+do_test "dav mkcol" test-dav-mkcol.sh
+do_test "dav put" test-dav-put.sh
 
-# mkcol
-printf "TEST: dav mkcol ... "
-./test-dav-mkcol.sh
-if [ $? -ne 0 ]; then
-	exit 2
-fi
-echo ok
-
-# put
-printf "TEST: dav put ... "
-./test-dav-put.sh
-if [ $? -ne 0 ]; then
-	exit 2
-fi
-echo ok
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bin-test/testdir/file1	Sun Jun 17 07:49:25 2018 +0200
@@ -0,0 +1,1 @@
+content 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bin-test/testdir/file2	Sun Jun 17 07:49:25 2018 +0200
@@ -0,0 +1,1 @@
+content 2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bin-test/testdir/file3	Sun Jun 17 07:49:25 2018 +0200
@@ -0,0 +1,1 @@
+content 3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bin-test/testdir/subdir/sub1	Sun Jun 17 07:49:25 2018 +0200
@@ -0,0 +1,1 @@
+123
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bin-test/testdir/subdir/sub2	Sun Jun 17 07:49:25 2018 +0200
@@ -0,0 +1,1 @@
+abc

mercurial