summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-01-01 15:51:09 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2017-01-01 15:51:09 +0000
commitbfad644e448077931e27814be9dfa6891db8619a (patch)
tree5b9c3e8f647793a8e9d055d9b35c47be3b2369af
parentDo lots more work with compile time formatter instead runtime formatters (diff)
downloadlibdbpp-sqlite-bfad644e448077931e27814be9dfa6891db8619a.tar.bz2
libdbpp-sqlite-bfad644e448077931e27814be9dfa6891db8619a.tar.xz
libdbpp-sqlite-bfad644e448077931e27814be9dfa6891db8619a.zip
Register mock db implementations
-rw-r--r--libsqlitepp/sqlite-connection.cpp2
-rw-r--r--libsqlitepp/sqlite-mock.cpp11
-rw-r--r--libsqlitepp/sqlite-mock.h1
3 files changed, 12 insertions, 2 deletions
diff --git a/libsqlitepp/sqlite-connection.cpp b/libsqlitepp/sqlite-connection.cpp
index 6545918..40f0304 100644
--- a/libsqlitepp/sqlite-connection.cpp
+++ b/libsqlitepp/sqlite-connection.cpp
@@ -3,6 +3,8 @@
#include "sqlite-selectcommand.h"
#include "sqlite-modifycommand.h"
+NAMEDFACTORY("sqlite", SQLite::Connection, DB::ConnectionFactory);
+
SQLite::ConnectionError::ConnectionError(sqlite3 * db) :
SQLite::Error(db)
{
diff --git a/libsqlitepp/sqlite-mock.cpp b/libsqlitepp/sqlite-mock.cpp
index bcacbde..6a2edb5 100644
--- a/libsqlitepp/sqlite-mock.cpp
+++ b/libsqlitepp/sqlite-mock.cpp
@@ -3,16 +3,23 @@
#include <boost/lexical_cast.hpp>
#include <boost/filesystem/operations.hpp>
+NAMEDFACTORY("sqlite", SQLite::Mock, DB::MockDatabaseFactory);
+
namespace SQLite {
-Mock::Mock(const std::string & name, const std::vector<boost::filesystem::path> & ss) :
+Mock::Mock(const std::string & root, const std::string & name, const std::vector<boost::filesystem::path> & ss) :
MockDatabase(name),
- testDbPath(boost::filesystem::path("/tmp") / "sqliteut" / boost::lexical_cast<std::string>(getpid()) / boost::lexical_cast<std::string>(++DB::MockDatabase::mocked))
+ testDbPath(boost::filesystem::path(root) / boost::lexical_cast<std::string>(getpid()) / boost::lexical_cast<std::string>(++DB::MockDatabase::mocked))
{
CreateNewDatabase();
PlaySchemaScripts(ss);
}
+Mock::Mock(const std::string & name, const std::vector<boost::filesystem::path> & ss) :
+ Mock("/tmp/sqliteut", name, ss)
+{
+}
+
DB::Connection *
Mock::openConnection() const
{
diff --git a/libsqlitepp/sqlite-mock.h b/libsqlitepp/sqlite-mock.h
index 8bd0899..66ec813 100644
--- a/libsqlitepp/sqlite-mock.h
+++ b/libsqlitepp/sqlite-mock.h
@@ -9,6 +9,7 @@ namespace SQLite {
class DLL_PUBLIC Mock : public DB::MockDatabase {
public:
+ Mock(const std::string & root, const std::string & name, const std::vector<boost::filesystem::path> & ss);
Mock(const std::string & name, const std::vector<boost::filesystem::path> & ss);
~Mock();