Compare commits
No commits in common. "a65084e04a5df3b7f59a3a9f2abd7d2294bef33e" and "7e1abab66d6fd6d723e2429f01d104dc1a06ec36" have entirely different histories.
a65084e04a
...
7e1abab66d
|
@ -234,8 +234,8 @@ impl Rooms {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_room_info(&self, room_id: &str) -> Result<Option<RoomInfo>, DataError> {
|
pub fn get_room_info(&self, info: &RoomInfo) -> Result<Option<RoomInfo>, DataError> {
|
||||||
let key = room_id.as_bytes();
|
let key = info.room_id.as_bytes();
|
||||||
|
|
||||||
let room_info: Option<RoomInfo> = self
|
let room_info: Option<RoomInfo> = self
|
||||||
.roomid_roominfo
|
.roomid_roominfo
|
||||||
|
@ -378,71 +378,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn insert_room_info_works() {
|
fn clear_info() {
|
||||||
let rooms = create_test_instance();
|
|
||||||
|
|
||||||
let 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");
|
|
||||||
|
|
||||||
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 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();
|
|
||||||
|
|
||||||
let found_info = rooms
|
|
||||||
.get_room_info("!fakeroom:example.com")
|
|
||||||
.expect("Error loading room info");
|
|
||||||
|
|
||||||
assert!(found_info.is_none());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn clear_info_modifies_removes_requested_room() {
|
|
||||||
let rooms = create_test_instance();
|
let rooms = create_test_instance();
|
||||||
|
|
||||||
rooms
|
rooms
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// RoomInfo has basic metadata about a room: its name, ID, etc.
|
/// RoomInfo has basic metadata about a room: its name, ID, etc.
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct RoomInfo {
|
pub struct RoomInfo {
|
||||||
pub room_id: String,
|
pub room_id: String,
|
||||||
pub room_name: String,
|
pub room_name: String,
|
||||||
|
|
Loading…
Reference in New Issue