8#include <kcenon/common/patterns/result.h>
60 bool matches(
const std::string& query)
const;
78 std::optional<core::database_result>
result_;
120 : std::runtime_error(message) {}
Exception thrown by mock when simulating errors.
backend_exception(const std::string &message)
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.
Abstract interface for database backends.
std::vector< database_row > database_result
backend_match_type
How to match query strings.
@ PATTERN
Regex pattern match.
@ EXACT
Exact string match.