@@ -838,17 +838,9 @@ mod tests {
838
838
use matrix_sdk_common:: executor:: spawn;
839
839
use matrix_sdk_test:: { async_test, sync_timeline_event} ;
840
840
use ruma:: room_id;
841
- use serde_json:: json;
842
- use wiremock:: {
843
- matchers:: { header, method, path_regex, query_param} ,
844
- Mock , ResponseTemplate ,
845
- } ;
846
841
847
842
use super :: { BackPaginationOutcome , EventCacheError } ;
848
- use crate :: {
849
- event_cache:: store:: PaginationToken ,
850
- test_utils:: { logged_in_client, logged_in_client_with_server} ,
851
- } ;
843
+ use crate :: { event_cache:: store:: PaginationToken , test_utils:: logged_in_client} ;
852
844
853
845
#[ async_test]
854
846
async fn test_must_explicitly_subscribe ( ) {
@@ -866,51 +858,57 @@ mod tests {
866
858
assert_matches ! ( result, Err ( EventCacheError :: NotSubscribedYet ) ) ;
867
859
}
868
860
869
- #[ async_test]
870
- async fn test_unknown_pagination_token ( ) {
871
- let ( client, server) = logged_in_client_with_server ( ) . await ;
872
-
873
- let room_id = room_id ! ( "!galette:saucisse.bzh" ) ;
874
- client. base_client ( ) . get_or_create_room ( room_id, matrix_sdk_base:: RoomState :: Joined ) ;
875
-
876
- client. event_cache ( ) . subscribe ( ) . unwrap ( ) ;
877
-
878
- let ( room_event_cache, _drop_handles) =
879
- client. event_cache ( ) . for_room ( room_id) . await . unwrap ( ) ;
880
- let room_event_cache = room_event_cache. unwrap ( ) ;
881
-
882
- // If I try to back-paginate with an unknown back-pagination token,
883
- let token_name = "unknown" ;
884
- let token = PaginationToken ( token_name. to_owned ( ) ) ;
885
-
886
- // Then I run into an error.
887
- Mock :: given ( method ( "GET" ) )
888
- . and ( path_regex ( r"^/_matrix/client/r0/rooms/.*/messages$" ) )
889
- . and ( header ( "authorization" , "Bearer 1234" ) )
890
- . and ( query_param ( "from" , token_name) )
891
- . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( {
892
- "start" : token_name,
893
- "chunk" : [ ] ,
894
- } ) ) )
895
- . expect ( 1 )
896
- . mount ( & server)
897
- . await ;
898
-
899
- let res = room_event_cache. backpaginate ( 20 , Some ( token) ) . await ;
900
- assert_matches ! ( res, Ok ( BackPaginationOutcome :: UnknownBackpaginationToken ) ) ;
901
-
902
- server. verify ( ) . await
903
- }
904
-
905
861
// Those tests require time to work, and it does not on wasm32.
906
862
#[ cfg( not( target_arch = "wasm32" ) ) ]
907
863
mod time_tests {
908
864
use std:: time:: { Duration , Instant } ;
909
865
910
866
use matrix_sdk_base:: RoomState ;
867
+ use serde_json:: json;
911
868
use tokio:: time:: sleep;
869
+ use wiremock:: {
870
+ matchers:: { header, method, path_regex, query_param} ,
871
+ Mock , ResponseTemplate ,
872
+ } ;
912
873
913
874
use super :: { super :: store:: Gap , * } ;
875
+ use crate :: test_utils:: logged_in_client_with_server;
876
+
877
+ #[ async_test]
878
+ async fn test_unknown_pagination_token ( ) {
879
+ let ( client, server) = logged_in_client_with_server ( ) . await ;
880
+
881
+ let room_id = room_id ! ( "!galette:saucisse.bzh" ) ;
882
+ client. base_client ( ) . get_or_create_room ( room_id, matrix_sdk_base:: RoomState :: Joined ) ;
883
+
884
+ client. event_cache ( ) . subscribe ( ) . unwrap ( ) ;
885
+
886
+ let ( room_event_cache, _drop_handles) =
887
+ client. event_cache ( ) . for_room ( room_id) . await . unwrap ( ) ;
888
+ let room_event_cache = room_event_cache. unwrap ( ) ;
889
+
890
+ // If I try to back-paginate with an unknown back-pagination token,
891
+ let token_name = "unknown" ;
892
+ let token = PaginationToken ( token_name. to_owned ( ) ) ;
893
+
894
+ // Then I run into an error.
895
+ Mock :: given ( method ( "GET" ) )
896
+ . and ( path_regex ( r"^/_matrix/client/r0/rooms/.*/messages$" ) )
897
+ . and ( header ( "authorization" , "Bearer 1234" ) )
898
+ . and ( query_param ( "from" , token_name) )
899
+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( json ! ( {
900
+ "start" : token_name,
901
+ "chunk" : [ ] ,
902
+ } ) ) )
903
+ . expect ( 1 )
904
+ . mount ( & server)
905
+ . await ;
906
+
907
+ let res = room_event_cache. backpaginate ( 20 , Some ( token) ) . await ;
908
+ assert_matches ! ( res, Ok ( BackPaginationOutcome :: UnknownBackpaginationToken ) ) ;
909
+
910
+ server. verify ( ) . await
911
+ }
914
912
915
913
#[ async_test]
916
914
async fn test_wait_no_pagination_token ( ) {
0 commit comments