mu-move: add new move sub command

Add sub-command to move messages; add tests and docs.

Fixes #157
This commit is contained in:
Dirk-Jan C. Binnema
2023-09-13 23:54:45 +03:00
parent 1a3dc46866
commit 2d20074b99
14 changed files with 597 additions and 90 deletions

View File

@ -71,13 +71,7 @@ make_test_store(const std::string& test_path, const TestMap& test_map,
assert_valid_result(store);
/* index the messages */
auto res = store->indexer().start({});
g_assert_true(res);
while(store->indexer().is_running()) {
using namespace std::chrono_literals;
std::this_thread::sleep_for(100ms);
}
g_assert_true(store->indexer().start({},true/*block*/));
if (test_map.size() > 0)
g_assert_false(store->empty());
@ -575,7 +569,7 @@ Boo!
assert_valid_result(moved_msgs);
g_assert_true(moved_msgs->size() == 1);
auto&& moved_msg_opt = store.find_message(moved_msgs->at(0));
auto&& moved_msg_opt = store.find_message(moved_msgs->at(0).first);
g_assert_true(!!moved_msg_opt);
const auto&moved_msg = std::move(*moved_msg_opt);
const auto new_path = moved_msg.path();

View File

@ -381,7 +381,7 @@ Yes, that would be excellent.
const auto msgs3 = store->move_message(msg->docid(), {}, Flags::Seen);
assert_valid_result(msgs3);
g_assert_true(msgs3->size() == 1);
auto&& msg3_opt{store->find_message(msgs3->at(0))};
auto&& msg3_opt{store->find_message(msgs3->at(0).first/*id*/)};
g_assert_true(!!msg3_opt);
auto&& msg3{std::move(*msg3_opt)};
@ -442,11 +442,11 @@ Yes, that would be excellent.
assert_valid_result(mres);
mu_info("found {} matches", mres->size());
for (auto&& m: *mres)
mu_info("id: {}", m);
mu_info("id: {}: {}", m.first, m.second);
// al three dups should have been updated
g_assert_cmpuint(mres->size(), ==, 3);
auto&& id_msgs{store->find_messages(*mres)};
auto&& id_msgs{store->find_messages(Store::id_vec(*mres))};
// first should be the original
g_assert_cmpuint(id_msgs.at(0).first, ==, ids.at(0));