/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "test-common.h"
#include "mail-index-private.h"
#include "mail-transaction-log-view-private.h"
const char *fmt ATTR_UNUSED, ...)
{
}
const char *fmt ATTR_UNUSED, ...)
{
}
{
}
struct mail_transaction_log_file **file_r,
const char **reason_r)
{
return 1;
}
}
*reason_r = "not found";
return 0;
}
const char **reason_r ATTR_UNUSED)
{
return 1;
}
const char **error_r ATTR_UNUSED)
{
*highest_modseq_r = 0;
return 0;
}
const void *data ATTR_UNUSED,
unsigned int version ATTR_UNUSED)
{
*cur_modseq += 1;
}
static void
{
/* files must be sorted by file_seq */
break;
}
}
*p = file;
}
{
unsigned int i, count;
for (i = 0; i < count; i++) {
}
}
return ret;
}
static size_t
const struct mail_index_record *rec)
{
return size;
}
static void test_mail_transaction_log_view(void)
{
const void *data;
void *oldfile;
const char *reason;
bool reset;
test_begin("init");
/* add an append record to the 3rd log file */
i_zero(&append_rec);
last_log_size = sizeof(struct mail_transaction_log_header) +
view_is_file_refed(3));
test_end();
/* we have files 1-3 opened */
test_begin("set all");
test_assert(mail_transaction_log_view_set(view, 0, 0, (uint32_t)-1, (uoff_t)-1, &reset, &reason) == 1 &&
view_is_file_refed(3) &&
test_end();
test_begin("set first");
test_end();
test_begin("set end");
test_assert(mail_transaction_log_view_set(view, 3, last_log_size, (uint32_t)-1, (uoff_t)-1, &reset, &reason) == 1);
test_end();
test_begin("log clear");
view_is_file_refed(3));
test_end();
/* --- first file has been removed --- */
test_begin("set 2-3");
test_assert(mail_transaction_log_view_set(view, 2, 0, (uint32_t)-1, (uoff_t)-1, &reset, &reason) == 1);
test_end();
test_begin("missing log handing");
test_assert(mail_transaction_log_view_set(view, 0, 0, (uint32_t)-1, (uoff_t)-1, &reset, &reason) == 0);
test_end();
test_begin("closed log handling");
test_assert(mail_transaction_log_view_set(view, 0, 0, (uint32_t)-1, (uoff_t)-1, &reset, &reason) == -1);
test_end();
}
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}