aboutsummaryrefslogtreecommitdiffstats
path: root/camel/tests/folder/test1.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@HelixCode.com>2000-11-28 21:13:23 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-11-28 21:13:23 +0800
commit3998a03ae925f47cd1ffcf31fca0a4701f8c75da (patch)
tree2e4abfb292e1e76da06af4ce5676fd7ae79d2c75 /camel/tests/folder/test1.c
parentf306b8b912a19e1a0321af66a29faf23664f2077 (diff)
downloadgsoc2013-evolution-3998a03ae925f47cd1ffcf31fca0a4701f8c75da.tar
gsoc2013-evolution-3998a03ae925f47cd1ffcf31fca0a4701f8c75da.tar.gz
gsoc2013-evolution-3998a03ae925f47cd1ffcf31fca0a4701f8c75da.tar.bz2
gsoc2013-evolution-3998a03ae925f47cd1ffcf31fca0a4701f8c75da.tar.lz
gsoc2013-evolution-3998a03ae925f47cd1ffcf31fca0a4701f8c75da.tar.xz
gsoc2013-evolution-3998a03ae925f47cd1ffcf31fca0a4701f8c75da.tar.zst
gsoc2013-evolution-3998a03ae925f47cd1ffcf31fca0a4701f8c75da.zip
Set the info size's properly, oops!
2000-11-28 Not Zed <NotZed@HelixCode.com> * providers/local/camel-maildir-summary.c (camel_maildir_summary_init): Set the info size's properly, oops! * tests/lib/folders.[ch]: Folder testing helpers. * tests/folder/test2.c: Test basic message ops on folders. * tests/folder/test1.c (main): Test basic folder ops on (local) stores. * providers/local/camel-local-provider.c (camel_provider_module_init): Removed some debug. * providers/local/camel-maildir-folder.c (camel_maildir_folder_class_init): fix parent class. * providers/local/camel-mh-folder.c (camel_mh_folder_class_init): Fix parent class (damn cut & paste). * providers/local/camel-maildir-store.c (get_folder): Call parent impl. (camel_maildir_store_class_init): Fix parent class setup. (delete_folder): Check the folder exists before trying to delete it. (delete_folder): Try and make the delete operation atomic/rollback failures. e.g. if one directory isn't empty, then create the other empty ones back. Also clear the tmp directory fully first. * providers/local/camel-mbox-store.c (get_folder): Call parent impl. (camel_mbox_store_class_init): parent class is camel_local_store, not camel_folder, oops. (delete_folder): Return an error if it doesn't exist, rather than covering it up. * providers/local/camel-mh-store.c (get_folder): Call parent impl. (camel_mh_store_class_init): fix parent class setup. (delete_folder): Error if it doesn't exist now. * camel-folder.c (camel_folder_move_message_to): (camel_folder_copy_message_to): Added warnings as these functions are going to be removed later. * camel-store.c (camel_store_get_root_folder): Fix for an early api change. We want CAMEL_STORE_FOLDER_CREATE, not TRUE, since its a flag. (camel_store_get_default_folder): And here too. * providers/local/camel-local-store.c (xrename): Handle renaming folders differently to renaming files. (get_default_folder_name): local stores dont have a default folder, so make it so. Or at least, it doesn't seem to make sense to have one. (get_root_folder_name): Same for root. (get_folder): Added parent implementation, that makes sure the service path exists, if we are creating a new folder (but doesn't create the folder). 2000-11-27 Not Zed <NotZed@HelixCode.com> * providers/local/camel-local-store.c (xrename): Fixed races. Use link/unlink, rather than rename, to properly detect overwriting another file. And allow some files to be missing. * providers/Makefile.am: Removed mh, mbox, added local, to the default. svn path=/trunk/; revision=6693
Diffstat (limited to 'camel/tests/folder/test1.c')
-rw-r--r--camel/tests/folder/test1.c149
1 files changed, 149 insertions, 0 deletions
diff --git a/camel/tests/folder/test1.c b/camel/tests/folder/test1.c
new file mode 100644
index 0000000000..020c511a82
--- /dev/null
+++ b/camel/tests/folder/test1.c
@@ -0,0 +1,149 @@
+/* store testing */
+
+#include "camel-test.h"
+
+#include <camel/camel-exception.h>
+#include <camel/camel-service.h>
+#include <camel/camel-session.h>
+#include <camel/camel-store.h>
+
+/* god, who designed this horrid interface */
+static char *auth_callback(CamelAuthCallbackMode mode,
+ char *data, gboolean secret,
+ CamelService *service, char *item,
+ CamelException *ex)
+{
+ return NULL;
+}
+
+#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
+
+static char *local_providers[] = {
+ "mbox",
+ "mh",
+ "maildir"
+};
+
+int main(int argc, char **argv)
+{
+ CamelSession *session;
+ CamelStore *store;
+ CamelException *ex;
+ CamelFolder *folder, *root;
+ int i;
+ char *path;
+
+ ex = camel_exception_new();
+
+ camel_test_init(argc, argv);
+
+ session = camel_session_new("/tmp/camel-test", auth_callback, NULL, NULL);
+
+ /* todo: cross-check everything with folder_info checks as well */
+ /* todo: subscriptions? */
+ /* todo: work out how to do imap/pop/nntp tests */
+ for (i=0;i<ARRAY_LEN(local_providers);i++) {
+ char *what = g_strdup_printf("testing local store: %s", local_providers[i]);
+
+ camel_test_start(what);
+ g_free(what);
+
+ push("getting store");
+ path = g_strdup_printf("%s:///tmp/camel-test/%s", local_providers[i], local_providers[i]);
+ store = camel_session_get_store(session, path, ex);
+ check_msg(!camel_exception_is_set(ex), "getting store: %s", camel_exception_get_description(ex));
+ check(store != NULL);
+ pull();
+
+ /* local providers == no root folder */
+ push("getting root folder");
+ root = camel_store_get_root_folder(store, ex);
+ check(camel_exception_is_set(ex));
+ check(root == NULL);
+ camel_exception_clear(ex);
+ pull();
+
+ /* same for default folder */
+ push("getting default folder");
+ root = camel_store_get_root_folder(store, ex);
+ check(camel_exception_is_set(ex));
+ check(root == NULL);
+ camel_exception_clear(ex);
+ pull();
+
+ push("getting a non-existant folder, no create");
+ folder = camel_store_get_folder(store, "unknown", 0, ex);
+ check(camel_exception_is_set(ex));
+ check(folder == NULL);
+ camel_exception_clear(ex);
+ pull();
+
+ push("getting a non-existant folder, with create");
+ folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, ex);
+ check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ check(folder != NULL);
+ camel_object_unref((CamelObject *)folder);
+ pull();
+
+ push("getting an existing folder");
+ folder = camel_store_get_folder(store, "testbox", 0, ex);
+ check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ check(folder != NULL);
+ camel_object_unref((CamelObject *)folder);
+ pull();
+
+ push("renaming a non-existant folder");
+ camel_store_rename_folder(store, "unknown1", "unknown2", ex);
+ check(camel_exception_is_set(ex));
+ camel_exception_clear(ex);
+ pull();
+
+ push("renaming an existing folder");
+ camel_store_rename_folder(store, "testbox", "testbox2", ex);
+ check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ pull();
+
+ push("opening the old name of a renamed folder");
+ folder = camel_store_get_folder(store, "testbox", 0, ex);
+ check(camel_exception_is_set(ex));
+ check(folder == NULL);
+ camel_exception_clear(ex);
+ pull();
+
+ push("opening the new name of a renamed folder");
+ folder = camel_store_get_folder(store, "testbox2", 0, ex);
+ check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ check(folder != NULL);
+ camel_object_unref((CamelObject *)folder);
+ pull();
+
+ push("deleting a non-existant folder");
+ camel_store_delete_folder(store, "unknown", ex);
+ check(camel_exception_is_set(ex));
+ camel_exception_clear(ex);
+ pull();
+
+ push("deleting an existing folder");
+ camel_store_delete_folder(store, "testbox2", ex);
+ check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
+ pull();
+
+ push("opening a folder that has been deleted");
+ folder = camel_store_get_folder(store, "testbox2", 0, ex);
+ check(camel_exception_is_set(ex));
+ check(folder == NULL);
+ camel_exception_clear(ex);
+ pull();
+
+ camel_object_unref((CamelObject *)store);
+
+ g_free(path);
+
+ camel_test_end();
+ }
+
+ camel_object_unref((CamelObject *)session);
+ camel_exception_free(ex);
+
+ return 0;
+}