13 , execute_success_(true)
15 , max_invocations_(std::numeric_limits<int>::max())
16 , actual_invocations_(0)
88 return std::regex_search(query,
pattern_);
107 return kcenon::common::Result<core::database_result>(kcenon::common::error_info{-1, *
error_message_});
115 return kcenon::common::Result<uint64_t>(kcenon::common::error_info{-1, *
error_message_});
117 return kcenon::common::Result<uint64_t>::ok(
rows_affected_.value_or(0));
123 return kcenon::common::VoidResult(kcenon::common::error_info{-1, *
error_message_});
125 return kcenon::common::VoidResult(std::monostate{});
138 : db_(db), exp_(std::move(exp))
Fluent builder for backend expectations.
backend_expectation_builder & will_fail(const std::string &error_message)
backend_expectation_builder & times(int count)
backend_expectation_builder & once()
backend_expectation_builder & any_times()
backend_expectation_builder & will_succeed()
backend_expectation_builder & will_return_rows(uint64_t count)
backend_expectation_builder & will_return(const core::database_result &result)
backend_expectation_builder(mock_backend *db, backend_expectation exp)
Single query expectation with configurable behavior for database_backend.
std::optional< uint64_t > rows_affected_
kcenon::common::Result< uint64_t > get_rows_affected()
bool should_error() const
backend_expectation & for_any()
backend_expectation & for_query(const std::string &query, backend_match_type type=backend_match_type::EXACT)
backend_expectation & at_least(int count)
backend_expectation & never()
std::string get_error_message() const
backend_expectation & returning(const core::database_result &result)
backend_expectation & at_most(int count)
std::optional< core::database_result > result_
bool can_be_invoked() const
kcenon::common::Result< core::database_result > get_select_result()
backend_expectation & for_pattern(const std::string &pattern)
bool is_satisfied() const
backend_expectation & times(int count)
backend_match_type match_type_
std::optional< std::string > error_message_
backend_expectation & returning_rows_affected(uint64_t count)
backend_expectation & returning_execute_success()
bool matches(const std::string &query) const
kcenon::common::VoidResult get_execute_result()
backend_expectation & returning_error(const std::string &error_message)
backend_expectation & once()
Configurable mock for database_backend interface.
std::vector< backend_expectation > expectations_
std::vector< database_row > database_result
backend_match_type
How to match query strings.
@ PATTERN
Regex pattern match.
@ EXACT
Exact string match.