//------------------------------------------------------------------------------ /* This file is part of clio: https://github.com/XRPLF/clio Copyright (c) 2023, the clio developers. Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== #include #include #include #include using namespace Backend::Cassandra; using namespace Backend::Cassandra::detail; struct FakeResult { }; struct FakeResultOrError { CassandraError err{"", CASS_OK}; operator bool() const { return err.code() == CASS_OK; } CassandraError error() const { return err; } FakeResult value() const { return FakeResult{}; } }; struct FakeMaybeError { }; struct FakeStatement { }; struct FakePreparedStatement { }; struct FakeFuture { FakeResultOrError data; FakeResultOrError get() const { return data; } }; struct FakeFutureWithCallback : public FakeFuture { }; struct MockHandle { using ResultOrErrorType = FakeResultOrError; using MaybeErrorType = FakeMaybeError; using FutureWithCallbackType = FakeFutureWithCallback; using FutureType = FakeFuture; using StatementType = FakeStatement; using PreparedStatementType = FakePreparedStatement; using ResultType = FakeResult; MOCK_METHOD( FutureWithCallbackType, asyncExecute, (StatementType const&, std::function&&), (const)); MOCK_METHOD( FutureWithCallbackType, asyncExecute, (std::vector const&, std::function&&), (const)); MOCK_METHOD(ResultOrErrorType, execute, (StatementType const&), (const)); }; struct FakeRetryPolicy { FakeRetryPolicy(boost::asio::io_context&){}; // required by concept std::chrono::milliseconds calculateDelay(uint32_t attempt) { return std::chrono::milliseconds{1}; } bool shouldRetry(CassandraError) const { return false; } template void retry(Fn&& fn) { fn(); } };