make object deleter replacable in the copy manager

This commit is contained in:
Sarah Hoffmann
2019-12-01 21:24:10 +01:00
parent f543a73f18
commit 6e8f3572da
10 changed files with 415 additions and 382 deletions

View File

@ -22,7 +22,8 @@ TEST_CASE("db_copy_thread_t")
table->id = "id";
db_copy_thread_t t(db.conninfo());
auto cmd = std::unique_ptr<db_cmd_copy_t>(new db_cmd_copy_t(table));
using cmd_copy_t = db_cmd_copy_delete_t<db_deleter_by_id_t>;
auto cmd = std::unique_ptr<cmd_copy_t>(new cmd_copy_t(table));
SECTION("simple copy command")
{
@ -66,12 +67,12 @@ TEST_CASE("db_copy_thread_t")
t.add_buffer(std::unique_ptr<db_cmd_t>(cmd.release()));
t.sync_and_wait();
cmd = std::unique_ptr<db_cmd_copy_t>(new db_cmd_copy_t(table));
cmd = std::unique_ptr<cmd_copy_t>(new cmd_copy_t(table));
SECTION("simple delete of existing rows")
{
cmd->deleter.add(223);
cmd->deleter.add(42);
cmd->add_deletable(223);
cmd->add_deletable(42);
t.add_buffer(std::unique_ptr<db_cmd_t>(cmd.release()));
t.sync_and_wait();
@ -82,7 +83,7 @@ TEST_CASE("db_copy_thread_t")
SECTION("delete one and add another")
{
cmd->deleter.add(133);
cmd->add_deletable(133);
cmd->buffer += "134\n";
t.add_buffer(std::unique_ptr<db_cmd_t>(cmd.release()));
@ -94,7 +95,7 @@ TEST_CASE("db_copy_thread_t")
SECTION("delete one and add the same")
{
cmd->deleter.add(133);
cmd->add_deletable(133);
cmd->buffer += "133\n";
t.add_buffer(std::unique_ptr<db_cmd_t>(cmd.release()));
@ -109,7 +110,7 @@ TEST_CASE("db_copy_thread_t")
cmd->buffer += "542\n5543\n10133\n";
t.add_buffer(std::unique_ptr<db_cmd_t>(cmd.release()));
cmd = std::unique_ptr<db_cmd_copy_t>(new db_cmd_copy_t(table));
cmd = std::unique_ptr<cmd_copy_t>(new cmd_copy_t(table));
cmd->buffer += "12\n784\n523\n";
t.add_buffer(std::unique_ptr<db_cmd_t>(cmd.release()));
@ -125,8 +126,8 @@ TEST_CASE("db_copy_thread_t")
cmd->buffer += "542\n5543\n10133\n";
t.add_buffer(std::unique_ptr<db_cmd_t>(cmd.release()));
cmd = std::unique_ptr<db_cmd_copy_t>(new db_cmd_copy_t(table));
cmd->deleter.add(542);
cmd = std::unique_ptr<cmd_copy_t>(new cmd_copy_t(table));
cmd->add_deletable(542);
cmd->buffer += "12\n";
t.add_buffer(std::unique_ptr<db_cmd_t>(cmd.release()));