test_index_move: extend unit test

Double-check the changed values are seen in a newly opened store.
This commit is contained in:
Dirk-Jan C. Binnema
2024-07-27 09:36:15 +03:00
parent 18c9b14c6d
commit c6e8f894c1

View File

@ -344,6 +344,10 @@ Yes, that would be excellent.
// Index it into a store.
TempDir tempdir;
::time_t msg3changed{};
Store::Id msg3id;
{
auto store{Store::make_new(tempdir.path(), tempdir2.path() + "/Maildir")};
assert_valid_result(store);
@ -374,6 +378,7 @@ Yes, that would be excellent.
g_debug("%s", msg->sexp().to_string().c_str());
// Move the message from new->cur
const auto oldchanged{msg->changed()};
std::this_thread::sleep_for(1s); /* ctime should change */
const auto msgs3 = store->move_message(msg->docid(), {}, Flags::Seen);
assert_valid_result(msgs3);
@ -381,13 +386,28 @@ Yes, that would be excellent.
auto&& msg3_opt{store->find_message(msgs3->at(0).first/*id*/)};
g_assert_true(!!msg3_opt);
auto&& msg3{std::move(*msg3_opt)};
msg3id = msg3.docid();
assert_equal(msg3.maildir(), "/a");
assert_equal(msg3.path(), tempdir2.path() + "/Maildir/a/cur/msg:2,S");
g_assert_true(::access(msg3.path().c_str(), R_OK)==0);
g_assert_false(::access(oldpath.c_str(), R_OK)==0);
g_debug("%s", msg3.sexp().to_string().c_str()); g_assert_cmpuint(store->size(), ==, 1);
// ensure that the changed value was updated properly.
msg3changed = msg->changed();
const auto changeddiff(msg3changed - oldchanged);
g_assert_true(changeddiff > 0 && changeddiff <= 2);
g_assert_cmpuint(store->size(), ==, 1);
}
// ensure the values are properly stored.
{
const auto store2{Store::make(tempdir.path())};
assert_valid_result(store2);
const auto msg4 = store2->find_message(msg3id);
g_assert_true(!!msg4);
assert_equal(msg4->path(), tempdir2.path() + "/Maildir/a/cur/msg:2,S");
g_assert_cmpuint(msg4->changed(), ==, msg3changed);
}
}