lib: xapian-db/config: more tests
...and xapian-db gets a small API update, update store as well.
This commit is contained in:
@ -90,8 +90,10 @@ make_db(const std::string& db_path, Flavor flavor)
|
||||
return Xapian::WritableDatabase(db_path, Xapian::DB_OPEN);
|
||||
case Flavor::CreateOverwrite:
|
||||
return Xapian::WritableDatabase(db_path, Xapian::DB_CREATE_OR_OVERWRITE);
|
||||
/* LCOV_EXCL_START*/
|
||||
default:
|
||||
throw std::logic_error("unknown flavor");
|
||||
/* LCOV_EXCL_STOP*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,3 +106,43 @@ XapianDb::XapianDb(const std::string& db_path, Flavor flavor) :
|
||||
|
||||
mu_debug("created {} / {}", flavor, *this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef BUILD_TESTS
|
||||
/*
|
||||
* Tests.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "utils/mu-test-utils.hh"
|
||||
#include "config.h"
|
||||
#include "mu-store.hh"
|
||||
|
||||
static void
|
||||
test_errors()
|
||||
{
|
||||
allow_warnings();
|
||||
|
||||
TempDir tdir;
|
||||
auto store = Store::make_new(tdir.path(), MU_TESTMAILDIR2);
|
||||
assert_valid_result(store);
|
||||
g_assert_true(store->empty());
|
||||
|
||||
XapianDb xdb(tdir.path(), Flavor::ReadOnly);
|
||||
g_assert_true(xdb.read_only());
|
||||
|
||||
g_assert_false(!!xdb.delete_document("Boo"));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
mu_test_init(&argc, &argv);
|
||||
|
||||
g_test_add_func("/xapian-db/errors", test_errors);
|
||||
|
||||
return g_test_run();
|
||||
}
|
||||
#endif /*BUILD_TESTS*/
|
||||
|
||||
Reference in New Issue
Block a user