test-mailbox.c revision d3280fe317a4598c0868cc440e7a1191c06d0db3
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (c) 2009-2010 Dovecot authors, see the included COPYING file */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#include "lib.h"
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#include "array.h"
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#include "mail-storage-private.h"
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#include "test-mail-storage.h"
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch#define TEST_UID_VALIDITY 1
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Boschstatic bool test_mailbox_is_readonly(struct mailbox *box ATTR_UNUSED)
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch{
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch return FALSE;
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch}
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Boschstatic bool test_mailbox_allow_new_keywords(struct mailbox *box ATTR_UNUSED)
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch{
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch return TRUE;
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch}
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Boschstatic int test_mailbox_enable(struct mailbox *box,
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch enum mailbox_feature features)
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch{
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch box->enabled_features |= features;
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch return 0;
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch}
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Boschstatic int test_mailbox_open(struct mailbox *box ATTR_UNUSED)
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch{
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch return 0;
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch}
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Boschstatic void test_mailbox_close(struct mailbox *box ATTR_UNUSED)
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch{
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic int
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_create(struct mailbox *box,
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch const struct mailbox_update *update ATTR_UNUSED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool directory ATTR_UNUSED)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
45324f1eafa565dbc65e4dd335de9507dead55e6Timo Sirainen "Test mailbox creation isn't supported");
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return -1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic int
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_update(struct mailbox *box,
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch const struct mailbox_update *update ATTR_UNUSED)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
833bed942977673526c72e79bccc09314fc57104Phil Carmody mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch "Test mailbox update isn't supported");
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return -1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic int test_mailbox_delete(struct mailbox *box)
e9228a3918aa0243eff4aae1ff5462bd3198417fTimo Sirainen{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch "Test mailbox delete isn't supported");
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return -1;
1e9296de32c9ddda40f33c06556cd568ddadf71fTimo Sirainen}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic int test_mailbox_rename(struct mailbox *src,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct mailbox *dest ATTR_UNUSED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch bool rename_children ATTR_UNUSED)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE,
1e9296de32c9ddda40f33c06556cd568ddadf71fTimo Sirainen "Test mailbox rename isn't supported");
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return -1;
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch}
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch
833bed942977673526c72e79bccc09314fc57104Phil Carmodystatic int test_mailbox_get_status(struct mailbox *box ATTR_UNUSED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch enum mailbox_status_items items ATTR_UNUSED,
833bed942977673526c72e79bccc09314fc57104Phil Carmody struct mailbox_status *status_r)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch memset(status_r, 0, sizeof(*status_r));
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch status_r->uidvalidity = TEST_UID_VALIDITY;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch status_r->uidnext = 1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return 0;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic struct mailbox_sync_context *
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_sync_init(struct mailbox *box,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch enum mailbox_sync_flags flags ATTR_UNUSED)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
1e9296de32c9ddda40f33c06556cd568ddadf71fTimo Sirainen struct mailbox_sync_context *ctx;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch ctx = i_new(struct mailbox_sync_context, 1);
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen ctx->box = box;
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen return ctx;
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen}
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Boschstatic bool
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Boschtest_mailbox_sync_next(struct mailbox_sync_context *ctx ATTR_UNUSED,
14bd2410de3a0261d9c53c6120915027262216bdTimo Sirainen struct mailbox_sync_rec *sync_rec_r ATTR_UNUSED)
14bd2410de3a0261d9c53c6120915027262216bdTimo Sirainen{
14bd2410de3a0261d9c53c6120915027262216bdTimo Sirainen return FALSE;
9f8cef4cbc49797053c343209ea13022fdbc5a63Stephan Bosch}
9f8cef4cbc49797053c343209ea13022fdbc5a63Stephan Bosch
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainenstatic int
9f8cef4cbc49797053c343209ea13022fdbc5a63Stephan Boschtest_mailbox_sync_deinit(struct mailbox_sync_context *ctx,
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen struct mailbox_sync_status *status_r)
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen{
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen if (status_r != NULL)
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen memset(status_r, 0, sizeof(*status_r));
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch i_free(ctx);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return 0;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic void test_mailbox_notify_changes(struct mailbox *box ATTR_UNUSED)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic struct mailbox_transaction_context *
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_transaction_begin(struct mailbox *box,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch enum mailbox_transaction_flags flags)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct mailbox_transaction_context *ctx;
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch ctx = i_new(struct mailbox_transaction_context, 1);
833bed942977673526c72e79bccc09314fc57104Phil Carmody ctx->box = box;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch ctx->flags = flags;
833bed942977673526c72e79bccc09314fc57104Phil Carmody i_array_init(&ctx->module_contexts, 5);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return ctx;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic void
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_transaction_rollback(struct mailbox_transaction_context *t)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch array_free(&t->module_contexts);
91a482473f200152d6713181c0e36f7a4f03ef6dTimo Sirainen i_free(t);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic int
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_transaction_commit(struct mailbox_transaction_context *t,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct mail_transaction_commit_changes *changes_r)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch changes_r->uid_validity = TEST_UID_VALIDITY;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_transaction_rollback(t);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return 0;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic struct mail_search_context *
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_search_init(struct mailbox_transaction_context *t,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct mail_search_args *args,
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainen const enum mail_sort_type *sort_program ATTR_UNUSED)
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainen{
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainen struct mail_search_context *ctx;
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainen
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainen ctx = i_new(struct mail_search_context, 1);
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainen ctx->transaction = t;
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch ctx->args = args;
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch i_array_init(&ctx->results, 5);
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch i_array_init(&ctx->module_contexts, 5);
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch return ctx;
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch}
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Boschstatic int test_mailbox_search_deinit(struct mail_search_context *ctx)
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch{
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch array_free(&ctx->results);
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch array_free(&ctx->module_contexts);
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch i_free(ctx);
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch return 0;
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch}
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Boschstatic bool
93ed69606237a08623f8294c060fa148880058f8Timo Sirainentest_mailbox_search_next_nonblock(struct mail_search_context *ctx ATTR_UNUSED,
93ed69606237a08623f8294c060fa148880058f8Timo Sirainen struct mail *mail ATTR_UNUSED,
93ed69606237a08623f8294c060fa148880058f8Timo Sirainen bool *tryagain_r)
93ed69606237a08623f8294c060fa148880058f8Timo Sirainen{
93ed69606237a08623f8294c060fa148880058f8Timo Sirainen *tryagain_r = FALSE;
93ed69606237a08623f8294c060fa148880058f8Timo Sirainen return FALSE;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic bool
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_search_next_update_seq(struct mail_search_context *ctx ATTR_UNUSED)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return FALSE;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic struct mail_save_context *
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_save_alloc(struct mailbox_transaction_context *t)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
711e8e4c5c5d702dfa062f42a1ede5de14c151c9Stephan Bosch struct mail_save_context *ctx;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch ctx = i_new(struct mail_save_context, 1);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch ctx->transaction = t;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return ctx;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
711e8e4c5c5d702dfa062f42a1ede5de14c151c9Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic int
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_save_begin(struct mail_save_context *ctx ATTR_UNUSED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct istream *input ATTR_UNUSED)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return -1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic int
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_save_continue(struct mail_save_context *ctx ATTR_UNUSED)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return -1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic int
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_save_finish(struct mail_save_context *ctx ATTR_UNUSED)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return -1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic void
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_save_cancel(struct mail_save_context *ctx ATTR_UNUSED)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic int
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_copy(struct mail_save_context *ctx ATTR_UNUSED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct mail *mail ATTR_UNUSED)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return -1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic bool test_mailbox_is_inconsistent(struct mailbox *box ATTR_UNUSED)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch return FALSE;
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct mailbox test_mailbox = {
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch .v = {
833bed942977673526c72e79bccc09314fc57104Phil Carmody test_mailbox_is_readonly,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_allow_new_keywords,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_enable,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_open,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_close,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch NULL,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_create,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_update,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_delete,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_rename,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_get_status,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch NULL,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch NULL,
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen NULL,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_sync_init,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_sync_next,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_sync_deinit,
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainen NULL,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_notify_changes,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_transaction_begin,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_transaction_commit,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_transaction_rollback,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch NULL,
711e8e4c5c5d702dfa062f42a1ede5de14c151c9Stephan Bosch test_mailbox_mail_alloc,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_search_init,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_search_deinit,
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch test_mailbox_search_next_nonblock,
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch test_mailbox_search_next_update_seq,
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch test_mailbox_save_alloc,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_save_begin,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_save_continue,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_save_finish,
b37e11d37fb1ebf50511eef5d9d96d1205818458Stephan Bosch test_mailbox_save_cancel,
b37e11d37fb1ebf50511eef5d9d96d1205818458Stephan Bosch test_mailbox_copy,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch test_mailbox_is_inconsistent
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch }
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch};
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct mailbox *
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschtest_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch const char *name, enum mailbox_flags flags)
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch{
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch struct mailbox *box;
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch pool_t pool;
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch pool = pool_alloconly_create("test mailbox", 1024);
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch box = p_new(pool, struct mailbox, 1);
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch *box = test_mailbox;
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch box->name = p_strdup(pool, name);
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch box->storage = storage;
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch box->list = list;
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen box->pool = pool;
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen box->flags = flags;
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen p_array_init(&box->search_results, pool, 16);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch p_array_init(&box->module_contexts, pool, 5);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch return box;
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen}
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainen