1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
# define BOOST_TEST_DYN_LINK
# define BOOST_TEST_MODULE TestOpenDb
# include <boost/test/unit_test.hpp>
# include <boost/filesystem.hpp>
# include "test_common.hh"
# include "db.hh"
# include "message_thread.hh"
# include "glibmm.h"
using namespace std;
using namespace Astroid;
using namespace boost::filesystem;
BOOST_AUTO_TEST_SUITE(DbTest)
BOOST_AUTO_TEST_CASE(open_confirm)
{
setup ();
const_cast<ptree&>(astroid->notmuch_config()).put ("database.path", "tests/mail/test_mail");
Db * db;
BOOST_CHECK_NO_THROW ( db = new Db (Db::DbMode::DATABASE_READ_ONLY) );
LOG (test) << "revision: " << db->get_revision ();
delete db;
teardown ();
}
//BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( open_rw, 1 )
BOOST_AUTO_TEST_CASE(open_rw)
{
setup ();
const_cast<ptree&>(astroid->notmuch_config()).put ("database.path", "tests/mail/test_mail");
Db * db;
BOOST_CHECK_NO_THROW ( db = new Db (Db::DbMode::DATABASE_READ_WRITE) );
LOG (test) << "revision: " << db->get_revision ();
//this_thread::sleep_for (chrono::milliseconds(5000));
delete db;
teardown ();
}
BOOST_AUTO_TEST_CASE(open_error)
{
setup ();
Db::path_db = path ("tests/mail/test_mail/non_existant");
Db * db;
BOOST_CHECK_THROW ( db = new Db (Db::DbMode::DATABASE_READ_ONLY), database_error );
(void) (db);
//delete db;
teardown ();
}
BOOST_AUTO_TEST_SUITE_END()
|