Add set_config_bool, fix rust test to test the current expected behavior

This commit is contained in:
Hocuri
2021-02-02 21:57:41 +01:00
parent e820d072f5
commit 8ac2cdd929
2 changed files with 33 additions and 14 deletions

View File

@@ -290,6 +290,11 @@ impl Context {
_ => self.sql.set_raw_config(self, key, value).await,
}
}
pub async fn set_config_bool(&self, key: Config, value: bool) -> crate::sql::Result<()> {
self.set_config(key, if value { Some("1") } else { None })
.await
}
}
/// Returns all available configuration keys concated together.

View File

@@ -1968,6 +1968,7 @@ mod tests {
true,
false,
false,
false,
)
.await;
}
@@ -1984,6 +1985,7 @@ mod tests {
false,
false,
false,
false,
)
.await;
}
@@ -1991,21 +1993,26 @@ mod tests {
#[async_std::test]
async fn test_needs_move_outgoing() {
// Test outgoing emails
for (folder, mvbox_move, chat_msg, mut expected_destination) in COMBINATIONS_ACCEPTED_CHAT {
if *folder == "INBOX" && !mvbox_move && *chat_msg {
expected_destination = "Sent"
for sentbox_move in &[true, false] {
// Test outgoing emails
for (folder, mvbox_move, chat_msg, mut expected_destination) in
COMBINATIONS_ACCEPTED_CHAT
{
if *folder == "INBOX" && !mvbox_move && *chat_msg && *sentbox_move {
expected_destination = "Sent"
}
check_needs_move_combination(
folder,
*mvbox_move,
*chat_msg,
expected_destination,
true,
true,
false,
*sentbox_move,
)
.await;
}
check_needs_move_combination(
folder,
*mvbox_move,
*chat_msg,
expected_destination,
true,
true,
false,
)
.await;
}
}
@@ -2021,11 +2028,13 @@ mod tests {
true,
true,
true,
false,
)
.await;
}
}
#[allow(clippy::too_many_arguments)]
async fn check_needs_move_combination(
folder: &str,
mvbox_move: bool,
@@ -2034,6 +2043,7 @@ mod tests {
accepted_chat: bool,
outgoing: bool,
setupmessage: bool,
sentbox_move: bool,
) {
use crate::dc_receive_imf::dc_receive_imf;
println!("Testing: For folder {}, mvbox_move {}, chat_msg {}, accepted {}, outgoing {}, setupmessage {}",
@@ -2060,6 +2070,10 @@ mod tests {
.set_config(Config::ShowEmails, Some("2"))
.await
.unwrap();
t.ctx
.set_config_bool(Config::SentboxMove, sentbox_move)
.await
.unwrap();
if accepted_chat {
let contact_id = Contact::create(&t.ctx, "", "bob@example.net")