Skip to content

Commit 3ec831f

Browse files
Hywanstefanceriu
authored andcommitted
test(base): Update tests after the previous patch.
This patch updates the tests, which now break because of the previous batch that fixes a bug.
1 parent ab34330 commit 3ec831f

File tree

2 files changed

+25
-31
lines changed

2 files changed

+25
-31
lines changed

crates/matrix-sdk-base/src/rooms/normal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3285,7 +3285,7 @@ mod tests {
32853285
assert!(context.room_info_notable_updates.contains_key(room_id));
32863286

32873287
// The subscriber isn't notified at this point.
3288-
assert!(room_info_notable_update.try_recv().is_err());
3288+
assert!(room_info_notable_update.is_empty());
32893289

32903290
// Then updating the room info will store the event,
32913291
processors::changes::save_and_apply(

crates/matrix-sdk-base/src/sliding_sync.rs

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,14 +1107,6 @@ mod tests {
11071107
let room = client.get_room(room_id).expect("No room found");
11081108
assert_eq!(room.cached_display_name().unwrap().to_string(), "Hello World");
11091109

1110-
assert_matches!(
1111-
room_info_notable_update.recv().await,
1112-
Ok(RoomInfoNotableUpdate { room_id: received_room_id, reasons }) => {
1113-
assert_eq!(received_room_id, room_id);
1114-
// Not the reason we are looking for.
1115-
assert!(!reasons.contains(RoomInfoNotableUpdateReasons::DISPLAY_NAME));
1116-
}
1117-
);
11181110
assert_matches!(
11191111
room_info_notable_update.recv().await,
11201112
Ok(RoomInfoNotableUpdate { room_id: received_room_id, reasons }) => {
@@ -1123,6 +1115,7 @@ mod tests {
11231115
assert!(reasons.contains(RoomInfoNotableUpdateReasons::DISPLAY_NAME));
11241116
}
11251117
);
1118+
assert!(room_info_notable_update.is_empty());
11261119
}
11271120

11281121
#[async_test]
@@ -1820,6 +1813,7 @@ mod tests {
18201813
assert!(!received_reasons.contains(RoomInfoNotableUpdateReasons::RECENCY_STAMP));
18211814
}
18221815
);
1816+
assert!(room_info_notable_update_stream.is_empty());
18231817

18241818
// When I send sliding sync response containing a room with a recency stamp.
18251819
let room = assign!(http::response::Room::new(), {
@@ -1839,6 +1833,7 @@ mod tests {
18391833
assert!(received_reasons.contains(RoomInfoNotableUpdateReasons::RECENCY_STAMP));
18401834
}
18411835
);
1836+
assert!(room_info_notable_update_stream.is_empty());
18421837
}
18431838

18441839
#[async_test]
@@ -1856,14 +1851,16 @@ mod tests {
18561851
.await
18571852
.expect("Failed to process sync");
18581853

1859-
// Then a room info notable update is NOT received.
1854+
// Then a room info notable update is received, but not the one we are
1855+
// interested by.
18601856
assert_matches!(
18611857
room_info_notable_update_stream.recv().await,
18621858
Ok(RoomInfoNotableUpdate { room_id: received_room_id, reasons: received_reasons }) => {
18631859
assert_eq!(received_room_id, room_id);
18641860
assert!(!received_reasons.contains(RoomInfoNotableUpdateReasons::READ_RECEIPT));
18651861
}
18661862
);
1863+
assert!(room_info_notable_update_stream.is_empty());
18671864

18681865
// When I send sliding sync response containing a couple of events with no read
18691866
// receipt.
@@ -1890,6 +1887,7 @@ mod tests {
18901887
assert!(received_reasons.contains(RoomInfoNotableUpdateReasons::READ_RECEIPT));
18911888
}
18921889
);
1890+
assert!(room_info_notable_update_stream.is_empty());
18931891
}
18941892

18951893
#[async_test]
@@ -1907,8 +1905,14 @@ mod tests {
19071905
.await
19081906
.expect("Failed to process sync");
19091907

1910-
// Discard first room info update
1911-
let _ = room_info_notable_update_stream.recv().await;
1908+
// Other notable update reason. We don't really care about them here.
1909+
assert_matches!(
1910+
room_info_notable_update_stream.recv().await,
1911+
Ok(RoomInfoNotableUpdate { room_id: received_room_id, reasons: received_reasons }) => {
1912+
assert_eq!(received_room_id, room_id);
1913+
assert!(received_reasons.contains(RoomInfoNotableUpdateReasons::DISPLAY_NAME));
1914+
}
1915+
);
19121916

19131917
// Send sliding sync response containing a membership event with 'join' value.
19141918
let room_id = room_id!("!r:e.uk");
@@ -1933,14 +1937,8 @@ mod tests {
19331937
.await
19341938
.expect("Failed to process sync");
19351939

1936-
// Room was already joined, no MEMBERSHIP update should be triggered here
1937-
assert_matches!(
1938-
room_info_notable_update_stream.recv().await,
1939-
Ok(RoomInfoNotableUpdate { room_id: received_room_id, reasons: received_reasons }) => {
1940-
assert_eq!(received_room_id, room_id);
1941-
assert!(!received_reasons.contains(RoomInfoNotableUpdateReasons::MEMBERSHIP));
1942-
}
1943-
);
1940+
// Room was already joined, no `MEMBERSHIP` update should be triggered here
1941+
assert!(room_info_notable_update_stream.is_empty());
19441942

19451943
let events = vec![Raw::from_json_string(
19461944
json!({
@@ -1964,14 +1962,14 @@ mod tests {
19641962
.expect("Failed to process sync");
19651963

19661964
// Then a room info notable update is received.
1967-
let update = room_info_notable_update_stream.recv().await;
19681965
assert_matches!(
1969-
update,
1966+
room_info_notable_update_stream.recv().await,
19701967
Ok(RoomInfoNotableUpdate { room_id: received_room_id, reasons: received_reasons }) => {
19711968
assert_eq!(received_room_id, room_id);
19721969
assert!(received_reasons.contains(RoomInfoNotableUpdateReasons::MEMBERSHIP));
19731970
}
19741971
);
1972+
assert!(room_info_notable_update_stream.is_empty());
19751973
}
19761974

19771975
#[async_test]
@@ -1989,14 +1987,15 @@ mod tests {
19891987
.await
19901988
.expect("Failed to process sync");
19911989

1992-
// Then a room info notable update is NOT received.
1990+
// Another notable update is received, but not the one we are interested by.
19931991
assert_matches!(
19941992
room_info_notable_update_stream.recv().await,
19951993
Ok(RoomInfoNotableUpdate { room_id: received_room_id, reasons: received_reasons }) => {
19961994
assert_eq!(received_room_id, room_id);
1997-
assert!(!received_reasons.contains(RoomInfoNotableUpdateReasons::UNREAD_MARKER));
1995+
assert!(received_reasons.contains(RoomInfoNotableUpdateReasons::DISPLAY_NAME), "{received_reasons:?}");
19981996
}
19991997
);
1998+
assert!(room_info_notable_update_stream.is_empty());
20001999

20012000
// When I receive a sliding sync response containing one update about an unread
20022001
// marker,
@@ -2035,13 +2034,7 @@ mod tests {
20352034
.await
20362035
.expect("Failed to process sync");
20372036

2038-
assert_matches!(
2039-
room_info_notable_update_stream.recv().await,
2040-
Ok(RoomInfoNotableUpdate { room_id: received_room_id, reasons: received_reasons }) => {
2041-
assert_eq!(received_room_id, room_id);
2042-
assert!(!received_reasons.contains(RoomInfoNotableUpdateReasons::UNREAD_MARKER));
2043-
}
2044-
);
2037+
assert!(room_info_notable_update_stream.is_empty());
20452038

20462039
// …Unless its value changes!
20472040
let room_account_data_events = vec![Raw::from_json_string(
@@ -2068,6 +2061,7 @@ mod tests {
20682061
assert!(received_reasons.contains(RoomInfoNotableUpdateReasons::UNREAD_MARKER));
20692062
}
20702063
);
2064+
assert!(room_info_notable_update_stream.is_empty());
20712065
}
20722066

20732067
#[async_test]

0 commit comments

Comments
 (0)