#include "sqlite-mock.h" #include "sqlite-connection.h" #include #include NAMEDFACTORY("sqlite", SQLite::Mock, DB::MockDatabaseFactory); namespace SQLite { Mock::Mock(const std::string & root, const std::string & name, const std::vector & ss) : MockDatabase(name), testDbPath(boost::filesystem::path(root) / boost::lexical_cast(getpid()) / boost::lexical_cast(++DB::MockDatabase::mocked)) { CreateNewDatabase(); PlaySchemaScripts(ss); } Mock::Mock(const std::string & name, const std::vector & ss) : Mock("/tmp/sqliteut", name, ss) { } DB::Connection * Mock::openConnection() const { return new Connection(testDbPath.string()); } Mock::~Mock() { DropDatabase(); } void Mock::DropDatabase() const { boost::filesystem::remove(testDbPath); } void Mock::CreateNewDatabase() const { boost::filesystem::create_directories(testDbPath.parent_path()); delete openConnection(); } }