mirror of
https://github.com/chatmail/core.git
synced 2026-05-20 07:16:31 +03:00
Add set_config_bool, fix rust test to test the current expected behavior
This commit is contained in:
@@ -290,6 +290,11 @@ impl Context {
|
|||||||
_ => self.sql.set_raw_config(self, key, value).await,
|
_ => 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.
|
/// Returns all available configuration keys concated together.
|
||||||
|
|||||||
@@ -1968,6 +1968,7 @@ mod tests {
|
|||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@@ -1984,6 +1985,7 @@ mod tests {
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@@ -1991,21 +1993,26 @@ mod tests {
|
|||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_needs_move_outgoing() {
|
async fn test_needs_move_outgoing() {
|
||||||
// Test outgoing emails
|
for sentbox_move in &[true, false] {
|
||||||
for (folder, mvbox_move, chat_msg, mut expected_destination) in COMBINATIONS_ACCEPTED_CHAT {
|
// Test outgoing emails
|
||||||
if *folder == "INBOX" && !mvbox_move && *chat_msg {
|
for (folder, mvbox_move, chat_msg, mut expected_destination) in
|
||||||
expected_destination = "Sent"
|
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,
|
true,
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
async fn check_needs_move_combination(
|
async fn check_needs_move_combination(
|
||||||
folder: &str,
|
folder: &str,
|
||||||
mvbox_move: bool,
|
mvbox_move: bool,
|
||||||
@@ -2034,6 +2043,7 @@ mod tests {
|
|||||||
accepted_chat: bool,
|
accepted_chat: bool,
|
||||||
outgoing: bool,
|
outgoing: bool,
|
||||||
setupmessage: bool,
|
setupmessage: bool,
|
||||||
|
sentbox_move: bool,
|
||||||
) {
|
) {
|
||||||
use crate::dc_receive_imf::dc_receive_imf;
|
use crate::dc_receive_imf::dc_receive_imf;
|
||||||
println!("Testing: For folder {}, mvbox_move {}, chat_msg {}, accepted {}, outgoing {}, setupmessage {}",
|
println!("Testing: For folder {}, mvbox_move {}, chat_msg {}, accepted {}, outgoing {}, setupmessage {}",
|
||||||
@@ -2060,6 +2070,10 @@ mod tests {
|
|||||||
.set_config(Config::ShowEmails, Some("2"))
|
.set_config(Config::ShowEmails, Some("2"))
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
t.ctx
|
||||||
|
.set_config_bool(Config::SentboxMove, sentbox_move)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
if accepted_chat {
|
if accepted_chat {
|
||||||
let contact_id = Contact::create(&t.ctx, "", "bob@example.net")
|
let contact_id = Contact::create(&t.ctx, "", "bob@example.net")
|
||||||
|
|||||||
Reference in New Issue
Block a user