@@ -73,6 +73,7 @@ macro_rules! sync_then_assert_request_and_fake_response {
7373 [ $server: ident, $room_list: ident, $stream: ident]
7474 $( states = $pre_state: pat => $post_state: pat, ) ?
7575 $( assert pos $pos: expr, ) ?
76+ $( assert timeout $timeout: expr, ) ?
7677 assert request $assert_request: tt { $( $request_json: tt ) * } ,
7778 respond with = $( ( code $code: expr ) ) ? { $( $response_json: tt ) * }
7879 $( , after delay = $response_delay: expr ) ?
@@ -83,6 +84,7 @@ macro_rules! sync_then_assert_request_and_fake_response {
8384 sync matches Some ( Ok ( _) ) ,
8485 $( states = $pre_state => $post_state, ) ?
8586 $( assert pos $pos, ) ?
87+ $( assert timeout $timeout, ) ?
8688 assert request $assert_request { $( $request_json ) * } ,
8789 respond with = $( ( code $code ) ) ? { $( $response_json ) * } ,
8890 $( after delay = $response_delay, ) ?
@@ -94,6 +96,7 @@ macro_rules! sync_then_assert_request_and_fake_response {
9496 sync matches $sync_result: pat,
9597 $( states = $pre_state: pat => $post_state: pat, ) ?
9698 $( assert pos $pos: expr, ) ?
99+ $( assert timeout $timeout: expr, ) ?
97100 assert request $assert_request: tt { $( $request_json: tt ) * } ,
98101 respond with = $( ( code $code: expr ) ) ? { $( $response_json: tt ) * }
99102 $( , after delay = $response_delay: expr ) ?
@@ -112,6 +115,7 @@ macro_rules! sync_then_assert_request_and_fake_response {
112115 [ $server, $stream]
113116 sync matches $sync_result,
114117 $( assert pos $pos, ) ?
118+ $( assert timeout $timeout, ) ?
115119 assert request $assert_request { $( $request_json ) * } ,
116120 respond with = $( ( code $code ) ) ? { $( $response_json ) * } ,
117121 $( after delay = $response_delay, ) ?
@@ -349,6 +353,10 @@ async fn test_sync_all_states() -> Result<(), Error> {
349353 sync_then_assert_request_and_fake_response ! {
350354 [ server, room_list, sync]
351355 states = Init => SettingUp ,
356+ // No `pos` because it's the first fresh query.
357+ assert pos None ,
358+ // No `timeout` because we don't want long-polling.
359+ assert timeout None ,
352360 assert request = {
353361 "conn_id" : "room-list" ,
354362 "lists" : {
@@ -393,7 +401,7 @@ async fn test_sync_all_states() -> Result<(), Error> {
393401 "pos" : "0" ,
394402 "lists" : {
395403 ALL_ROOMS : {
396- "count" : 420 ,
404+ "count" : 220 ,
397405 } ,
398406 } ,
399407 "rooms" : {
@@ -406,6 +414,10 @@ async fn test_sync_all_states() -> Result<(), Error> {
406414 sync_then_assert_request_and_fake_response ! {
407415 [ server, room_list, sync]
408416 states = SettingUp => Running ,
417+ // The previous `pos`.
418+ assert pos Some ( "0" ) ,
419+ // Still no long-polling because the list isn't fully-loaded.
420+ assert timeout None ,
409421 assert request = {
410422 "conn_id" : "room-list" ,
411423 "lists" : {
@@ -419,7 +431,7 @@ async fn test_sync_all_states() -> Result<(), Error> {
419431 "pos" : "1" ,
420432 "lists" : {
421433 ALL_ROOMS : {
422- "count" : 420 ,
434+ "count" : 220 ,
423435 } ,
424436 } ,
425437 "rooms" : {
@@ -431,6 +443,9 @@ async fn test_sync_all_states() -> Result<(), Error> {
431443 sync_then_assert_request_and_fake_response ! {
432444 [ server, room_list, sync]
433445 states = Running => Running ,
446+ assert pos Some ( "1" ) ,
447+ // Still no long-polling because the list isn't fully-loaded.
448+ assert timeout None ,
434449 assert request = {
435450 "conn_id" : "room-list" ,
436451 "lists" : {
@@ -444,7 +459,7 @@ async fn test_sync_all_states() -> Result<(), Error> {
444459 "pos" : "2" ,
445460 "lists" : {
446461 ALL_ROOMS : {
447- "count" : 420 ,
462+ "count" : 220 ,
448463 } ,
449464 } ,
450465 "rooms" : {
@@ -456,11 +471,15 @@ async fn test_sync_all_states() -> Result<(), Error> {
456471 sync_then_assert_request_and_fake_response ! {
457472 [ server, room_list, sync]
458473 states = Running => Running ,
474+ assert pos Some ( "2" ) ,
475+ // Still no long-polling because the list isn't fully-loaded,
476+ // but it's about to be!
477+ assert timeout None ,
459478 assert request = {
460479 "conn_id" : "room-list" ,
461480 "lists" : {
462481 ALL_ROOMS : {
463- "ranges" : [ [ 0 , 299 ] ] ,
482+ "ranges" : [ [ 0 , 219 ] ] ,
464483 "timeline_limit" : 1 ,
465484 } ,
466485 } ,
@@ -469,7 +488,7 @@ async fn test_sync_all_states() -> Result<(), Error> {
469488 "pos" : "3" ,
470489 "lists" : {
471490 ALL_ROOMS : {
472- "count" : 420 ,
491+ "count" : 220 ,
473492 } ,
474493 } ,
475494 "rooms" : {
@@ -481,11 +500,14 @@ async fn test_sync_all_states() -> Result<(), Error> {
481500 sync_then_assert_request_and_fake_response ! {
482501 [ server, room_list, sync]
483502 states = Running => Running ,
503+ assert pos Some ( "3" ) ,
504+ // The list is fully-loaded, we can start long-polling.
505+ assert timeout Some ( 30000 ) ,
484506 assert request = {
485507 "conn_id" : "room-list" ,
486508 "lists" : {
487509 ALL_ROOMS : {
488- "ranges" : [ [ 0 , 399 ] ] ,
510+ "ranges" : [ [ 0 , 219 ] ] ,
489511 "timeline_limit" : 1 ,
490512 } ,
491513 } ,
@@ -494,7 +516,7 @@ async fn test_sync_all_states() -> Result<(), Error> {
494516 "pos" : "4" ,
495517 "lists" : {
496518 ALL_ROOMS : {
497- "count" : 420 ,
519+ "count" : 220 ,
498520 } ,
499521 } ,
500522 "rooms" : {
0 commit comments