File tree Expand file tree Collapse file tree 1 file changed +28
-3
lines changed
firebase-firestore/src/test/java/com/google/firebase/firestore/bundle Expand file tree Collapse file tree 1 file changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -570,9 +570,34 @@ public void testDecodesLimitQuery() throws JSONException {
570
570
571
571
@ Test
572
572
public void testDecodesLimitToLastQuery () throws JSONException {
573
- String json = "{ from: [ { collectionId: 'coll' } ], limit: {value: 5 } }" ;
574
- Query query = TestUtil .query ("coll" ).orderBy (orderBy ("__name__" , "desc" )).limitToLast (5 );
575
- assertDecodesNamedQuery (json , query );
573
+ String queryJson =
574
+ "{\n "
575
+ + " name: 'query-1',\n "
576
+ + " bundledQuery: {\n "
577
+ + " parent: '"
578
+ + TEST_PROJECT
579
+ + "',\n "
580
+ + " structuredQuery:\n "
581
+ + "{ from: [ { collectionId: 'coll' } ], limit: {value: 5 } }"
582
+ + ",\n "
583
+ + " limitType: 'LAST'\n "
584
+ + " },\n "
585
+ + " readTime: '2020-01-01T00:00:01.000000001Z'\n "
586
+ + "}" ;
587
+ NamedQuery actualNamedQuery = serializer .decodeNamedQuery (new JSONObject (queryJson ));
588
+
589
+ // Note we use limitToFirst instead of limitToLast to avoid order reverse.
590
+ // Because this is what is saved in bundle files.
591
+ Query query = TestUtil .query ("coll" ).limitToFirst (5 );
592
+ Target target = query .toTarget ();
593
+ BundledQuery bundledQuery = new BundledQuery (target , Query .LimitType .LIMIT_TO_LAST );
594
+ NamedQuery expectedNamedQuery =
595
+ new NamedQuery (
596
+ "query-1" ,
597
+ bundledQuery ,
598
+ new SnapshotVersion (new com .google .firebase .Timestamp (1577836801 , 1 )));
599
+
600
+ assertEquals (expectedNamedQuery , actualNamedQuery );
576
601
}
577
602
578
603
@ Test
You can’t perform that action at this time.
0 commit comments