@@ -924,146 +924,146 @@ describeSpec('Limbo Documents:', [], () => {
924
924
) ;
925
925
926
926
specTest (
927
- 'A limbo resolution for a document should be removed from the queue when the last query listen stops ' ,
927
+ 'A limbo resolution for a document should not be started if one is already active ' ,
928
928
[ ] ,
929
929
( ) => {
930
- const doc1 = doc ( 'collection1/doc' , 1000 , { key : 1 } ) ;
931
- const query1 = query ( 'collection1' ) ;
932
- const filteredQuery1 = query ( 'collection1' , filter ( 'key' , '==' , 1 ) ) ;
933
-
934
- const doc2 = doc ( 'collection2/doc' , 1000 , { key : 2 } ) ;
935
- const query2 = query ( 'collection2' ) ;
936
- const filteredQuery2 = query ( 'collection2' , filter ( 'key' , '==' , 2 ) ) ;
937
- const filteredQuery3 = query ( 'collection2' , filter ( 'key' , '>=' , 2 ) ) ;
930
+ const doc1 = doc ( 'collection/doc' , 1000 , { key : 1 } ) ;
931
+ const fullQuery = query ( 'collection' ) ;
932
+ const filteredQuery1 = query ( 'collection' , filter ( 'key' , '==' , 1 ) ) ;
933
+ const filteredQuery2 = query ( 'collection' , filter ( 'key' , '>=' , 1 ) ) ;
938
934
939
935
return (
940
936
spec ( )
941
937
. withGCEnabled ( false )
942
- . withMaxConcurrentLimboResolutions ( 1 )
943
938
944
- // Max out the number of active limbo resolutions .
945
- . userListens ( query1 )
946
- . watchAcksFull ( query1 , 1000 , doc1 )
947
- . expectEvents ( query1 , { added : [ doc1 ] } )
948
- . userUnlistens ( query1 )
939
+ // Start a limbo resolution listen for a document (doc1) .
940
+ . userListens ( fullQuery )
941
+ . watchAcksFull ( fullQuery , 1000 , doc1 )
942
+ . expectEvents ( fullQuery , { added : [ doc1 ] } )
943
+ . userUnlistens ( fullQuery )
949
944
. userListens ( filteredQuery1 )
950
945
. expectEvents ( filteredQuery1 , { added : [ doc1 ] , fromCache : true } )
951
946
. watchAcksFull ( filteredQuery1 , 1001 )
952
947
. expectLimboDocs ( doc1 . key )
948
+ . expectEnqueuedLimboDocs ( )
953
949
954
- // Enqueue a limbo resolution for doc2.
955
- . userListens ( query2 )
956
- . watchAcksFull ( query2 , 1002 , doc2 )
957
- . expectEvents ( query2 , { added : [ doc2 ] } )
958
- . userUnlistens ( query2 )
950
+ // Put doc1 into limbo in a different query; verify that another limbo
951
+ // resolution is neither started nor enqueued.
959
952
. userListens ( filteredQuery2 )
960
- . expectEvents ( filteredQuery2 , { added : [ doc2 ] , fromCache : true } )
961
- . watchAcksFull ( filteredQuery2 , 1003 )
962
- . expectLimboDocs ( doc1 . key )
963
- . expectEnqueuedLimboDocs ( doc2 . key )
964
-
965
- // Start another query that puts doc2 into limbo again.
966
- . userListens ( filteredQuery3 )
967
- . expectEvents ( filteredQuery3 , { added : [ doc2 ] , fromCache : true } )
968
- . watchAcksFull ( filteredQuery3 , 1004 )
969
- . expectLimboDocs ( doc1 . key )
970
- . expectEnqueuedLimboDocs ( doc2 . key )
971
-
972
- // Stop one of the queries that enqueued a limbo resolution for doc2;
973
- // verify that doc2 is not removed from the limbo resolution queue.
974
- . userUnlistens ( filteredQuery3 )
975
- . expectLimboDocs ( doc1 . key )
976
- . expectEnqueuedLimboDocs ( doc2 . key )
977
-
978
- // Stop the other query that enqueued a limbo resolution for doc2;
979
- // verify that doc2 *is* removed from the limbo resolution queue.
980
- . userUnlistens ( filteredQuery2 )
953
+ . expectEvents ( filteredQuery2 , { added : [ doc1 ] , fromCache : true } )
954
+ . watchAcksFull ( filteredQuery2 , 1002 )
981
955
. expectLimboDocs ( doc1 . key )
982
956
. expectEnqueuedLimboDocs ( )
983
957
) ;
984
958
}
985
959
) ;
986
960
987
961
specTest (
988
- 'A limbo resolution for a document should not be started if one is already active ' ,
962
+ 'A limbo resolution for a document should not be enqueued if one is already enqueued ' ,
989
963
[ ] ,
990
964
( ) => {
991
- const doc1 = doc ( 'collection/doc' , 1000 , { key : 1 } ) ;
992
- const query1 = query ( 'collection' ) ;
993
- const filteredQuery1 = query ( 'collection' , filter ( 'key' , '==' , 1 ) ) ;
994
- const filteredQuery2 = query ( 'collection' , filter ( 'key' , '>=' , 1 ) ) ;
965
+ const doc1 = doc ( 'collection1/doc1' , 1000 , { key : 1 } ) ;
966
+ const fullQuery1 = query ( 'collection1' ) ;
967
+ const filteredQuery1 = query ( 'collection1' , filter ( 'key' , '==' , 1 ) ) ;
968
+ const doc2 = doc ( 'collection2/doc2' , 1000 , { key : 2 } ) ;
969
+ const fullQuery2 = query ( 'collection2' ) ;
970
+ const filteredQuery2a = query ( 'collection2' , filter ( 'key' , '==' , 2 ) ) ;
971
+ const filteredQuery2b = query ( 'collection2' , filter ( 'key' , '>=' , 2 ) ) ;
995
972
996
973
return (
997
974
spec ( )
998
975
. withGCEnabled ( false )
976
+ . withMaxConcurrentLimboResolutions ( 1 )
999
977
1000
- // Start a limbo resolution listen for a document (doc1) .
1001
- . userListens ( query1 )
1002
- . watchAcksFull ( query1 , 1000 , doc1 )
1003
- . expectEvents ( query1 , { added : [ doc1 ] } )
1004
- . userUnlistens ( query1 )
978
+ // Max out the number of active limbo resolutions .
979
+ . userListens ( fullQuery1 )
980
+ . watchAcksFull ( fullQuery1 , 1000 , doc1 )
981
+ . expectEvents ( fullQuery1 , { added : [ doc1 ] } )
982
+ . userUnlistens ( fullQuery1 )
1005
983
. userListens ( filteredQuery1 )
1006
984
. expectEvents ( filteredQuery1 , { added : [ doc1 ] , fromCache : true } )
1007
985
. watchAcksFull ( filteredQuery1 , 1001 )
1008
986
. expectLimboDocs ( doc1 . key )
1009
- . expectEnqueuedLimboDocs ( )
1010
987
1011
- // Put doc1 into limbo in a different query; verify that another limbo
1012
- // resolution is neither started nor enqueued.
1013
- . userListens ( filteredQuery2 )
1014
- . expectEvents ( filteredQuery2 , { added : [ doc1 ] , fromCache : true } )
1015
- . watchAcksFull ( filteredQuery2 , 1002 )
988
+ // Start a limbo resolution listen for a different document (doc2).
989
+ . userListens ( fullQuery2 )
990
+ . watchAcksFull ( fullQuery2 , 1002 , doc2 )
991
+ . expectEvents ( fullQuery2 , { added : [ doc2 ] } )
992
+ . userUnlistens ( fullQuery2 )
993
+ . userListens ( filteredQuery2a )
994
+ . expectEvents ( filteredQuery2a , { added : [ doc2 ] , fromCache : true } )
995
+ . watchAcksFull ( filteredQuery2a , 1003 )
1016
996
. expectLimboDocs ( doc1 . key )
1017
- . expectEnqueuedLimboDocs ( )
997
+ . expectEnqueuedLimboDocs ( doc2 . key )
998
+
999
+ // Put doc2 into limbo in a different query and verify that it's not
1000
+ // added to the limbo resolution queue again.
1001
+ . userListens ( filteredQuery2b )
1002
+ . expectEvents ( filteredQuery2b , { added : [ doc2 ] , fromCache : true } )
1003
+ . watchAcksFull ( filteredQuery2b , 1004 )
1004
+ . expectLimboDocs ( doc1 . key )
1005
+ . expectEnqueuedLimboDocs ( doc2 . key )
1018
1006
) ;
1019
1007
}
1020
1008
) ;
1021
1009
1022
1010
specTest (
1023
- 'A limbo resolution for a document should not be enqueued if one is already enqueued ' ,
1011
+ 'A limbo resolution for a document should be removed from the queue when the last query listen stops ' ,
1024
1012
[ ] ,
1025
1013
( ) => {
1026
- const doc1 = doc ( 'collection1/doc1 ' , 1000 , { key : 1 } ) ;
1027
- const query1 = query ( 'collection1' ) ;
1014
+ const doc1 = doc ( 'collection1/doc ' , 1000 , { key : 1 } ) ;
1015
+ const fullQuery1 = query ( 'collection1' ) ;
1028
1016
const filteredQuery1 = query ( 'collection1' , filter ( 'key' , '==' , 1 ) ) ;
1029
- const doc2 = doc ( 'collection2/doc2' , 1000 , { key : 2 } ) ;
1030
- const query2 = query ( 'collection2' ) ;
1031
- const filteredQuery2 = query ( 'collection2' , filter ( 'key' , '==' , 2 ) ) ;
1032
- const filteredQuery3 = query ( 'collection2' , filter ( 'key' , '>=' , 2 ) ) ;
1017
+
1018
+ const doc2 = doc ( 'collection2/doc' , 1000 , { key : 2 } ) ;
1019
+ const fullQuery2 = query ( 'collection2' ) ;
1020
+ const filteredQuery2a = query ( 'collection2' , filter ( 'key' , '==' , 2 ) ) ;
1021
+ const filteredQuery2b = query ( 'collection2' , filter ( 'key' , '>=' , 2 ) ) ;
1033
1022
1034
1023
return (
1035
1024
spec ( )
1036
1025
. withGCEnabled ( false )
1037
1026
. withMaxConcurrentLimboResolutions ( 1 )
1038
1027
1039
1028
// Max out the number of active limbo resolutions.
1040
- . userListens ( query1 )
1041
- . watchAcksFull ( query1 , 1000 , doc1 )
1042
- . expectEvents ( query1 , { added : [ doc1 ] } )
1043
- . userUnlistens ( query1 )
1029
+ . userListens ( fullQuery1 )
1030
+ . watchAcksFull ( fullQuery1 , 1000 , doc1 )
1031
+ . expectEvents ( fullQuery1 , { added : [ doc1 ] } )
1032
+ . userUnlistens ( fullQuery1 )
1044
1033
. userListens ( filteredQuery1 )
1045
1034
. expectEvents ( filteredQuery1 , { added : [ doc1 ] , fromCache : true } )
1046
1035
. watchAcksFull ( filteredQuery1 , 1001 )
1047
1036
. expectLimboDocs ( doc1 . key )
1048
1037
1049
- // Start a limbo resolution listen for a different document ( doc2) .
1050
- . userListens ( query2 )
1051
- . watchAcksFull ( query2 , 1002 , doc2 )
1052
- . expectEvents ( query2 , { added : [ doc2 ] } )
1053
- . userUnlistens ( query2 )
1054
- . userListens ( filteredQuery2 )
1055
- . expectEvents ( filteredQuery2 , { added : [ doc2 ] , fromCache : true } )
1056
- . watchAcksFull ( filteredQuery2 , 1003 )
1038
+ // Enqueue a limbo resolution for doc2.
1039
+ . userListens ( fullQuery2 )
1040
+ . watchAcksFull ( fullQuery2 , 1002 , doc2 )
1041
+ . expectEvents ( fullQuery2 , { added : [ doc2 ] } )
1042
+ . userUnlistens ( fullQuery2 )
1043
+ . userListens ( filteredQuery2a )
1044
+ . expectEvents ( filteredQuery2a , { added : [ doc2 ] , fromCache : true } )
1045
+ . watchAcksFull ( filteredQuery2a , 1003 )
1057
1046
. expectLimboDocs ( doc1 . key )
1058
1047
. expectEnqueuedLimboDocs ( doc2 . key )
1059
1048
1060
- // Put doc2 into limbo in a different query and verify that it's not
1061
- // added to the limbo resolution queue again.
1062
- . userListens ( filteredQuery3 )
1063
- . expectEvents ( filteredQuery3 , { added : [ doc2 ] , fromCache : true } )
1064
- . watchAcksFull ( filteredQuery3 , 1004 )
1049
+ // Start another query that puts doc2 into limbo again.
1050
+ . userListens ( filteredQuery2b )
1051
+ . expectEvents ( filteredQuery2b , { added : [ doc2 ] , fromCache : true } )
1052
+ . watchAcksFull ( filteredQuery2b , 1004 )
1053
+ . expectLimboDocs ( doc1 . key )
1054
+ . expectEnqueuedLimboDocs ( doc2 . key )
1055
+
1056
+ // Stop one of the queries that enqueued a limbo resolution for doc2;
1057
+ // verify that doc2 is not removed from the limbo resolution queue.
1058
+ . userUnlistens ( filteredQuery2b )
1065
1059
. expectLimboDocs ( doc1 . key )
1066
1060
. expectEnqueuedLimboDocs ( doc2 . key )
1061
+
1062
+ // Stop the other query that enqueued a limbo resolution for doc2;
1063
+ // verify that doc2 *is* removed from the limbo resolution queue.
1064
+ . userUnlistens ( filteredQuery2a )
1065
+ . expectLimboDocs ( doc1 . key )
1066
+ . expectEnqueuedLimboDocs ( )
1067
1067
) ;
1068
1068
}
1069
1069
) ;
0 commit comments