From a65084e04a5df3b7f59a3a9f2abd7d2294bef33e Mon Sep 17 00:00:00 2001 From: projectmoon Date: Sun, 29 Nov 2020 21:33:46 +0000 Subject: [PATCH] Unit test for updating room info data. --- src/db/rooms.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/db/rooms.rs b/src/db/rooms.rs index 4fa0e2d..be79fd3 100644 --- a/src/db/rooms.rs +++ b/src/db/rooms.rs @@ -400,6 +400,36 @@ mod tests { assert_eq!(info, found_info.unwrap()); } + #[test] + fn insert_room_info_updates_data() { + let rooms = create_test_instance(); + + let mut info = RoomInfo { + room_id: matrix_sdk::identifiers::room_id!("!fakeroom:example.com") + .as_str() + .to_owned(), + room_name: "fake room name".to_owned(), + }; + + rooms + .insert_room_info(&info) + .expect("Could insert room info"); + + //Update info to have a new room name before inserting again. + info.room_name = "new fake room name".to_owned(); + + rooms + .insert_room_info(&info) + .expect("Could insert room info"); + + let found_info = rooms + .get_room_info("!fakeroom:example.com") + .expect("Error loading room info"); + + assert!(found_info.is_some()); + assert_eq!(info, found_info.unwrap()); + } + #[test] fn get_room_info_none_when_room_does_not_exist() { let rooms = create_test_instance();