src/server/test/webdav.c

branch
webdav
changeset 220
2915b6c11aec
parent 219
dd6c155c082a
child 221
ff5826fc6a6c
equal deleted inserted replaced
219:dd6c155c082a 220:2915b6c11aec
35 #include "../webdav/requestparser.h" 35 #include "../webdav/requestparser.h"
36 #include "../webdav/webdav.h" 36 #include "../webdav/webdav.h"
37 #include "../webdav/multistatus.h" 37 #include "../webdav/multistatus.h"
38 #include "../webdav/operation.h" 38 #include "../webdav/operation.h"
39 39
40 #include "vfs.h"
40 #include "webdav.h" 41 #include "webdav.h"
41 42
42 /* ----------------------------- Test Backends --------------------------*/ 43 /* ----------------------------- Test Backends --------------------------*/
43 44
44 static int backend2_init_called = 0; 45 static int backend2_init_called = 0;
788 UCX_TEST_ASSERT(backend1_propfind_do_count == 1, "backend1 propfind_do not called"); 789 UCX_TEST_ASSERT(backend1_propfind_do_count == 1, "backend1 propfind_do not called");
789 UCX_TEST_ASSERT(backend2_propfind_do_count == 1, "backend2 propfind_do not called"); 790 UCX_TEST_ASSERT(backend2_propfind_do_count == 1, "backend2 propfind_do not called");
790 791
791 792
792 UCX_TEST_END; 793 UCX_TEST_END;
794 testutil_destroy_session(sn);
793 } 795 }
794 796
795 UCX_TEST(test_webdav_op_propfind_children) { 797 UCX_TEST(test_webdav_op_propfind_children) {
796 reset_backends(); 798 reset_backends();
797 799
803 UCX_TEST_ASSERT(op, "WebdavOperation not created"); 805 UCX_TEST_ASSERT(op, "WebdavOperation not created");
804 806
805 int err = webdav_op_propfind_begin(op, "/", NULL, NULL); 807 int err = webdav_op_propfind_begin(op, "/", NULL, NULL);
806 UCX_TEST_ASSERT(err == 0, "propfind_begin error"); 808 UCX_TEST_ASSERT(err == 0, "propfind_begin error");
807 809
808 810 // create test vfs with some files (code from test_vfs_readdir)
809 811 rq->vfs = testvfs_create(sn);
812 VFSContext *vfs = vfs_request_context(sn, rq);
813 UCX_TEST_ASSERT(vfs, "no vfs");
814
815 err = vfs_mkdir(vfs, "/dir");
816 UCX_TEST_ASSERT(err == 0, "error not 0");
817
818 // add some test file to /dir
819 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file1", O_CREAT), "creation of file1 failed");
820 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file2", O_CREAT), "creation of file2 failed");
821 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file3", O_CREAT), "creation of file3 failed");
822 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file4", O_CREAT), "creation of file4 failed");
823
824 VFSDir *dir = vfs_opendir(vfs, "/dir");
825 UCX_TEST_ASSERT(dir, "dir not opened");
826
827 UCX_TEST_ASSERT(backend1_propfind_do_count == 1, "backend1 propfind_do not called");
828 UCX_TEST_ASSERT(backend2_propfind_do_count == 1, "backend1 propfind_do not called")
829
830 // propfind for all children
831 err = webdav_op_propfind_children(op, vfs, "/dir");
832 UCX_TEST_ASSERT(err == 0, "webdav_op_propfind_children failed");
833
834 // 1 dir + 4 children
835 UCX_TEST_ASSERT(backend1_propfind_do_count == 5, "backend1 propfind_do wrong count");
836 UCX_TEST_ASSERT(backend2_propfind_do_count == 5, "backend2 propfind_do wrong count");
810 837
811 UCX_TEST_END; 838 UCX_TEST_END;
812 } 839 testutil_destroy_session(sn);
840 }

mercurial