From 9413206bd1f4d9b0c7543ebb2eb1bb469303a32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20A=C3=9Fmann?= Date: Sat, 3 Jun 2017 11:20:18 +0200 Subject: [PATCH] Hide the "isolation_level" member of the MockDb to make it explicit that this is only used for mock validation --- tests/MockDb.h | 10 ++++++++-- tests/Select.cpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/MockDb.h b/tests/MockDb.h index 1da2d555..91ab34d0 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -35,6 +35,11 @@ #include #include +// an object to store internal Mock flags and values to validate in tests +struct InternalMockData { + sqlpp::isolation_level _last_isolation_level; +}; + template struct MockDbT : public sqlpp::connection { @@ -248,7 +253,8 @@ struct MockDbT : public sqlpp::connection 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) @@ -260,7 +266,7 @@ struct MockDbT : public sqlpp::connection void report_rollback_failure(std::string) {} - sqlpp::isolation_level _current_isolation_level; + InternalMockData _mock_data; }; using MockDb = MockDbT; diff --git a/tests/Select.cpp b/tests/Select.cpp index 78b1daca..b475b642 100644 --- a/tests/Select.cpp +++ b/tests/Select.cpp @@ -184,7 +184,7 @@ int Select(int, char* []) } 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; }