mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 11:26:29 +03:00
in set_chat_name(), bind value to sql using ?-operator, add a test to check the name is really changed
This commit is contained in:
committed by
holger krekel
parent
b8057b7ddb
commit
b766a55b0a
24
src/chat.rs
24
src/chat.rs
@@ -1719,12 +1719,8 @@ pub fn set_chat_name(
|
|||||||
if sql::execute(
|
if sql::execute(
|
||||||
context,
|
context,
|
||||||
&context.sql,
|
&context.sql,
|
||||||
format!(
|
"UPDATE chats SET name=? WHERE id=?;",
|
||||||
"UPDATE chats SET name='{}' WHERE id={};",
|
params![new_name.as_ref(), chat_id as i32],
|
||||||
new_name.as_ref(),
|
|
||||||
chat_id as i32
|
|
||||||
),
|
|
||||||
params![],
|
|
||||||
)
|
)
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
@@ -2345,4 +2341,20 @@ mod tests {
|
|||||||
assert_eq!(chatlist_len(&t.ctx, DC_GCL_NO_SPECIALS), 1);
|
assert_eq!(chatlist_len(&t.ctx, DC_GCL_NO_SPECIALS), 1);
|
||||||
assert_eq!(chatlist_len(&t.ctx, DC_GCL_ARCHIVED_ONLY), 1);
|
assert_eq!(chatlist_len(&t.ctx, DC_GCL_ARCHIVED_ONLY), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_set_chat_name() {
|
||||||
|
let t = dummy_context();
|
||||||
|
let chat_id = create_group_chat(&t.ctx, VerifiedStatus::Unverified, "foo").unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
Chat::load_from_db(&t.ctx, chat_id).unwrap().get_name(),
|
||||||
|
"foo"
|
||||||
|
);
|
||||||
|
|
||||||
|
set_chat_name(&t.ctx, chat_id, "bar").unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
Chat::load_from_db(&t.ctx, chat_id).unwrap().get_name(),
|
||||||
|
"bar"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user