test-dsync-proxy-server-cmd.c revision 3fe67ec75ccae1230bb9eb9f16affc48377f6441
/* Copyright (c) 2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "strescape.h"
#include "istream.h"
#include "ostream.h"
#include "master-service.h"
#include "test-common.h"
#include "dsync-proxy-server.h"
#include "test-dsync-worker.h"
#include "test-dsync-common.h"
#define ALL_MAIL_FLAGS "\\Answered \\Flagged \\Deleted \\Seen \\Draft \\Recent"
struct master_service *master_service;
static struct dsync_proxy_server *server;
static struct test_dsync_worker *test_worker;
static struct dsync_proxy_server_command *cur_cmd;
static const char *cur_cmd_args[20];
static void out_clear(void)
{
str_truncate(out, 0);
}
static int run_more(void)
{
int ret;
if (ret == 0)
return 0;
return ret;
}
static int ATTR_SENTINEL
{
const char *str;
unsigned int i = 0;
cur_cmd_args[i++] = str;
}
cur_cmd_args[i] = NULL;
return run_more();
}
static void test_dsync_proxy_box_list(void)
{
struct dsync_mailbox box;
test_begin("proxy server box list");
/* \noselect mailbox */
test_assert(run_more() == 0);
out_clear();
/* selectable mailbox */
test_assert(run_more() == 0);
TEST_MAILBOX_GUID2"\t0\t0\t"
"4275878552\t"
"4023233417\t"
"18080787909545915012\n") == 0);
out_clear();
/* last mailbox */
out_clear();
test_end();
}
static void test_dsync_proxy_subs_list(void)
{
const char *name;
struct dsync_worker_subscription subs;
struct dsync_worker_unsubscription unsubs;
test_begin("proxy server subs list");
/* subscription */
name = "\t\001\r\nname\t\001\n\r";
test_assert(run_more() == 0);
"\t1234567890\n", NULL)) == 0);
out_clear();
test_assert(run_more() == 0);
out_clear();
/* unsubscription */
test_assert(run_more() == 0);
out_clear();
out_clear();
test_end();
}
static void test_dsync_proxy_msg_list(void)
{
static const char *test_keywords[] = {
};
struct dsync_message msg;
struct test_dsync_worker_msg test_msg;
test_begin("proxy server msg list");
/* no flags */
test_assert(run_more() == 0);
"\t123\t98765432101234\t\t1234567890\n", NULL)) == 0);
out_clear();
/* all flags, some keywords */
test_assert(run_more() == 0);
ALL_MAIL_FLAGS" kw1 kw2\t2\n") == 0);
out_clear();
/* last message */
out_clear();
test_end();
}
static void test_dsync_proxy_box_create(void)
{
struct test_dsync_box_event event;
test_begin("proxy server box create");
test_end();
}
static void test_dsync_proxy_box_delete(void)
{
struct test_dsync_box_event event;
test_begin("proxy server box delete");
test_end();
}
static void test_dsync_proxy_box_rename(void)
{
struct test_dsync_box_event event;
test_begin("proxy server box rename");
test_end();
}
static void test_dsync_proxy_box_update(void)
{
struct test_dsync_box_event event;
test_begin("proxy server box update");
test_end();
}
static void test_dsync_proxy_box_select(void)
{
test_begin("proxy server box select");
test_assert(memcmp(test_worker->selected_mailbox.guid, test_mailbox_guid1, MAIL_GUID_128_SIZE) == 0);
test_assert(memcmp(test_worker->selected_mailbox.guid, test_mailbox_guid2, MAIL_GUID_128_SIZE) == 0);
test_end();
}
static void test_dsync_proxy_msg_update(void)
{
struct test_dsync_msg_event event;
test_begin("proxy server msg update");
test_end();
}
static void test_dsync_proxy_msg_uid_change(void)
{
struct test_dsync_msg_event event;
test_begin("proxy server msg uid change");
test_end();
}
static void test_dsync_proxy_msg_expunge(void)
{
struct test_dsync_msg_event event;
test_begin("proxy server msg expunge");
test_end();
}
static void test_dsync_proxy_msg_copy(void)
{
struct test_dsync_msg_event msg_event;
test_begin("proxy server msg copy");
"copyguid", "5678", "74782482882924", "\\Seen foo \\Draft",
test_end();
}
static void test_dsync_proxy_msg_save(void)
{
static const char *input = "..dotty\n..behavior\nfrom you\n.\nstop";
struct test_dsync_msg_event event;
const unsigned char *data;
test_begin("proxy server msg save");
"saveguid", "874", "33982482882924", "\\Flagged bar \\Answered",
test_end();
}
static struct dsync_proxy_server *
{
struct dsync_proxy_server *server;
return server;
}
int main(void)
{
static void (*test_functions[])(void) = {
};
test_init();
return test_deinit();
}