Keep mailbox flags safe and no-op updates unchanged (by Codex)
This commit is contained in:
1 parent
9101770614
commit
0fc26624d9
3 files changed
+20
-3
No files matched your search
@@ -836,6 +836,8 @@ int main(int argc, char** argv) {
|
||||
const auto update = [&](const char* action, int n) {
|
||||
return session.ui_command(cmd("request:nu" + std::to_string(n), "news.update", O{{"messageId", id}, {"action", action}}), rev);
|
||||
};
|
||||
const auto no_op_marks=session.state().news_marks;const auto no_op_revision=rev;
|
||||
check(s(at(update("unread",0),"outcome"))=="no_change"&&session.state().news_marks==no_op_marks&&rev==no_op_revision,"mailbox: no-op must not create an empty owner map");
|
||||
update("read", 1);
|
||||
const std::string after_read = folder_of();
|
||||
update("archive", 2);
|
||||
@@ -849,6 +851,9 @@ int main(int argc, char** argv) {
|
||||
check(after_read == "inbox+read" && after_archive == "archive+read" && after_trash == "trash+read" &&
|
||||
after_restore == "inbox+read", "mailbox: read, archive, trash, restore");
|
||||
check(s(at(update("restore", 5), "outcome")) == "no_change", "mailbox: an unchanged mark is no change");
|
||||
update("unread",7);check(folder_of()=="inbox","mailbox: clearing the last mark is safe");
|
||||
const auto cleared_marks=session.state().news_marks;const auto cleared_revision=rev;
|
||||
check(s(at(update("unread",8),"outcome"))=="no_change"&&session.state().news_marks==cleared_marks&&rev==cleared_revision,"mailbox: repeated clearing is write-free");
|
||||
check(s(at(session.ui_command(cmd("request:nu6", "news.update", O{{"messageId", "message:none"}, {"action", "read"}}), rev), "code")) ==
|
||||
"unknown_message", "mailbox: unknown message");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user