mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Hide the "isolation_level" member of the MockDb to make it explicit that
this is only used for mock validation
This commit is contained in:
parent
ee20a8be67
commit
9413206bd1
@ -35,6 +35,11 @@
|
|||||||
#include <sqlpp11/serializer_context.h>
|
#include <sqlpp11/serializer_context.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
// an object to store internal Mock flags and values to validate in tests
|
||||||
|
struct InternalMockData {
|
||||||
|
sqlpp::isolation_level _last_isolation_level;
|
||||||
|
};
|
||||||
|
|
||||||
template <bool enforceNullResultTreatment>
|
template <bool enforceNullResultTreatment>
|
||||||
struct MockDbT : public sqlpp::connection
|
struct MockDbT : public sqlpp::connection
|
||||||
{
|
{
|
||||||
@ -248,7 +253,8 @@ struct MockDbT : public sqlpp::connection
|
|||||||
|
|
||||||
void start_transaction(sqlpp::isolation_level level)
|
void start_transaction(sqlpp::isolation_level level)
|
||||||
{
|
{
|
||||||
_current_isolation_level = level;
|
// store temporarily to verify the expected level was used in testcases
|
||||||
|
_mock_data._last_isolation_level = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rollback_transaction(bool)
|
void rollback_transaction(bool)
|
||||||
@ -260,7 +266,7 @@ struct MockDbT : public sqlpp::connection
|
|||||||
void report_rollback_failure(std::string)
|
void report_rollback_failure(std::string)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
sqlpp::isolation_level _current_isolation_level;
|
InternalMockData _mock_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
using MockDb = MockDbT<false>;
|
using MockDb = MockDbT<false>;
|
||||||
|
@ -184,7 +184,7 @@ int Select(int, char* [])
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto transaction = start_transaction(db, sqlpp::isolation_level::read_committed);
|
auto transaction = start_transaction(db, sqlpp::isolation_level::read_committed);
|
||||||
std::cout << (db._current_isolation_level == sqlpp::isolation_level::read_committed) << std::endl;
|
std::cout << (db._mock_data._last_isolation_level == sqlpp::isolation_level::read_committed) << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user