3#include <Lightweight/SqlBackup.hpp>
4#include <Lightweight/SqlBackup/BatchManager.hpp>
12namespace Lightweight::SqlBackup::Tests
15struct LambdaProgressManager: SqlBackup::ProgressManager
17 mutable std::mutex mutex;
18 std::function<void(SqlBackup::Progress
const&)> callback;
20 explicit LambdaProgressManager(std::function<
void(SqlBackup::Progress
const&)> cb):
21 callback(std::move(cb))
25 void Update(SqlBackup::Progress
const& p)
override
27 auto const lock = std::scoped_lock(mutex);
32 void AllDone()
override
38struct ScopedFileRemoved
40 std::filesystem::path path;
42 void RemoveIfExists()
const
45 if (std::filesystem::exists(path, ec))
46 std::filesystem::remove(path, ec);
49 explicit ScopedFileRemoved(std::filesystem::path path):
60 ScopedFileRemoved(ScopedFileRemoved
const&) =
delete;
61 ScopedFileRemoved& operator=(ScopedFileRemoved
const&) =
delete;
62 ScopedFileRemoved(ScopedFileRemoved&&) =
delete;
63 ScopedFileRemoved& operator=(ScopedFileRemoved&&) =
delete;
66template <
typename Executor>
67void RunBatchManagerTest(Executor&& executor,
68 std::vector<SqlColumnDeclaration>
const& cols,
69 std::vector<std::vector<SqlBackup::BackupValue>>
const& rows,
71 SqlServerType serverType = SqlServerType::UNKNOWN)
73 Lightweight::detail::BatchManager bm(std::forward<Executor>(executor), cols, capacity, serverType);
74 for (
auto const& row: rows)
79template <
typename Executor>
80void RunBatchManagerBatchTest(Executor&& executor,
81 std::vector<SqlColumnDeclaration>
const& cols,
82 std::vector<SqlBackup::ColumnBatch>
const& batches,
84 SqlServerType serverType = SqlServerType::UNKNOWN)
86 Lightweight::detail::BatchManager bm(std::forward<Executor>(executor), cols, capacity, serverType);
87 for (
auto const& batch: batches)