@@ -469,61 +469,6 @@ - (void)testTerminateDoesNotCrashWithFlyingAggregateQuery {
469
469
[NSNumber numberWithLong: 150L ], );
470
470
}
471
471
472
- - (void )testCanPerformMaxAggregations {
473
- XCTSkipIf (![FSTIntegrationTestCase isRunningAgainstEmulator ],
474
- " Skip this test if running against production because it requires a composite index." );
475
- FIRCollectionReference* testCollection = [self collectionRefWithDocuments: @{
476
- @" a" : @{
477
- @" author" : @" authorA" ,
478
- @" title" : @" titleA" ,
479
- @" pages" : @100 ,
480
- @" height" : @24.5 ,
481
- @" weight" : @24.1 ,
482
- @" foo" : @1 ,
483
- @" bar" : @2 ,
484
- @" baz" : @3
485
- },
486
- @" b" : @{
487
- @" author" : @" authorB" ,
488
- @" title" : @" titleB" ,
489
- @" pages" : @50 ,
490
- @" height" : @25.5 ,
491
- @" weight" : @75.5 ,
492
- @" foo" : @1 ,
493
- @" bar" : @2 ,
494
- @" baz" : @3
495
- }
496
- }];
497
-
498
- // Max is 5, do not exceed
499
- FIRAggregateQuerySnapshot* snapshot =
500
- [self readSnapshotForAggregate: [testCollection aggregate: @[
501
- [FIRAggregateField aggregateFieldForCount ],
502
- [FIRAggregateField aggregateFieldForSumOfField: @" pages" ],
503
- [FIRAggregateField aggregateFieldForSumOfField: @" weight" ],
504
- [FIRAggregateField aggregateFieldForAverageOfField: @" pages" ],
505
- [FIRAggregateField aggregateFieldForAverageOfField: @" weight" ]
506
- ]]];
507
-
508
- // Assert
509
- XCTAssertEqual ([snapshot valueForAggregateField: [FIRAggregateField aggregateFieldForCount ]],
510
- [NSNumber numberWithLong: 2L ]);
511
- XCTAssertEqual (
512
- [snapshot valueForAggregateField: [FIRAggregateField aggregateFieldForSumOfField: @" pages" ]],
513
- [NSNumber numberWithLong: 150L ], );
514
- XCTAssertEqual (
515
- [[snapshot valueForAggregateField: [FIRAggregateField aggregateFieldForSumOfField: @" weight" ]]
516
- doubleValue ],
517
- 99.6 );
518
- XCTAssertEqual ([snapshot valueForAggregateField: [FIRAggregateField
519
- aggregateFieldForAverageOfField: @" pages" ]],
520
- [NSNumber numberWithDouble: 75.0 ]);
521
- XCTAssertEqual ([[snapshot valueForAggregateField: [FIRAggregateField
522
- aggregateFieldForAverageOfField: @" weight" ]]
523
- doubleValue ],
524
- 49.8 );
525
- }
526
-
527
472
- (void )testCannotPerformMoreThanMaxAggregations {
528
473
FIRCollectionReference* testCollection = [self collectionRefWithDocuments: @{
529
474
@" a" : @{
@@ -574,105 +519,6 @@ - (void)testCannotPerformMoreThanMaxAggregations {
574
519
XCTAssertTrue ([[result localizedDescription ] containsString: @" maximum number of aggregations" ]);
575
520
}
576
521
577
- - (void )testCanRunAggregateCollectionGroupQuery {
578
- XCTSkipIf (![FSTIntegrationTestCase isRunningAgainstEmulator ],
579
- " Skip this test if running against production because it requires a composite index." );
580
-
581
- NSString * collectionGroup =
582
- [NSString stringWithFormat: @" %@%@ " , @" b" ,
583
- [self .db collectionWithPath: @" foo" ].documentWithAutoID.documentID];
584
- NSArray * docPathFormats = @[
585
- @" abc/123/%@ /cg-doc1" , @" abc/123/%@ /cg-doc2" , @" %@ /cg-doc3" , @" %@ /cg-doc4" ,
586
- @" def/456/%@ /cg-doc5" , @" %@ /virtual-doc/nested-coll/not-cg-doc" , @" x%@ /not-cg-doc" ,
587
- @" %@ x/not-cg-doc" , @" abc/123/%@ x/not-cg-doc" , @" abc/123/x%@ /not-cg-doc" , @" abc/%@ "
588
- ];
589
-
590
- FIRWriteBatch* batch = self.db .batch ;
591
- for (NSString * format in docPathFormats) {
592
- NSString * path = [NSString stringWithFormat: format, collectionGroup];
593
- [batch setData: @{@" x" : @2 } forDocument: [self .db documentWithPath: path]];
594
- }
595
- [self commitWriteBatch: batch];
596
-
597
- FIRAggregateQuerySnapshot* snapshot =
598
- [self readSnapshotForAggregate: [[self .db collectionGroupWithID: collectionGroup] aggregate: @[
599
- [FIRAggregateField aggregateFieldForCount ],
600
- [FIRAggregateField aggregateFieldForSumOfField: @" x" ],
601
- [FIRAggregateField aggregateFieldForAverageOfField: @" x" ]
602
- ]]];
603
- // "cg-doc1", "cg-doc2", "cg-doc3", "cg-doc4", "cg-doc5",
604
- XCTAssertEqual ([snapshot valueForAggregateField: [FIRAggregateField aggregateFieldForCount ]],
605
- [NSNumber numberWithLong: 5L ]);
606
- XCTAssertEqual (
607
- [snapshot valueForAggregateField: [FIRAggregateField aggregateFieldForSumOfField: @" x" ]],
608
- [NSNumber numberWithLong: 10L ]);
609
- XCTAssertEqual (
610
- [snapshot valueForAggregateField: [FIRAggregateField aggregateFieldForAverageOfField: @" x" ]],
611
- [NSNumber numberWithDouble: 2.0 ]);
612
- }
613
-
614
- - (void )testPerformsAggregationsWhenNaNExistsForSomeFieldValues {
615
- XCTSkipIf (![FSTIntegrationTestCase isRunningAgainstEmulator ],
616
- " Skip this test if running against production because it requires a composite index." );
617
-
618
- FIRCollectionReference* testCollection = [self collectionRefWithDocuments: @{
619
- @" a" : @{
620
- @" author" : @" authorA" ,
621
- @" title" : @" titleA" ,
622
- @" pages" : @100 ,
623
- @" year" : @1980 ,
624
- @" rating" : @5
625
- },
626
- @" b" : @{
627
- @" author" : @" authorB" ,
628
- @" title" : @" titleB" ,
629
- @" pages" : @50 ,
630
- @" year" : @2020 ,
631
- @" rating" : @4
632
- },
633
- @" c" : @{
634
- @" author" : @" authorC" ,
635
- @" title" : @" titleC" ,
636
- @" pages" : @100 ,
637
- @" year" : @1980 ,
638
- @" rating" : [NSNumber numberWithFloat: NAN]
639
- },
640
- @" d" : @{
641
- @" author" : @" authorD" ,
642
- @" title" : @" titleD" ,
643
- @" pages" : @50 ,
644
- @" year" : @2020 ,
645
- @" rating" : @0
646
- }
647
- }];
648
-
649
- FIRAggregateQuerySnapshot* snapshot =
650
- [self readSnapshotForAggregate: [testCollection aggregate: @[
651
- [FIRAggregateField aggregateFieldForSumOfField: @" rating" ],
652
- [FIRAggregateField aggregateFieldForSumOfField: @" pages" ],
653
- [FIRAggregateField aggregateFieldForAverageOfField: @" rating" ],
654
- [FIRAggregateField aggregateFieldForAverageOfField: @" year" ]
655
- ]]];
656
-
657
- // Sum
658
- XCTAssertEqual (
659
- [snapshot valueForAggregateField: [FIRAggregateField aggregateFieldForSumOfField: @" rating" ]],
660
- [NSNumber numberWithDouble: NAN]);
661
- XCTAssertEqual (
662
- [[snapshot valueForAggregateField: [FIRAggregateField aggregateFieldForSumOfField: @" pages" ]]
663
- longValue ],
664
- 300L );
665
-
666
- // Average
667
- XCTAssertEqual ([snapshot valueForAggregateField: [FIRAggregateField
668
- aggregateFieldForAverageOfField: @" rating" ]],
669
- [NSNumber numberWithDouble: NAN]);
670
- XCTAssertEqual (
671
- [[snapshot valueForAggregateField: [FIRAggregateField aggregateFieldForAverageOfField: @" year" ]]
672
- doubleValue ],
673
- 2000.0 );
674
- }
675
-
676
522
- (void )testThrowsAnErrorWhenGettingTheResultOfAnUnrequestedAggregation {
677
523
FIRCollectionReference* testCollection = [self collectionRefWithDocuments: @{
678
524
@" a" : @{
@@ -789,77 +635,6 @@ - (void)testPerformsAggregationWhenUsingInOperator {
789
635
4.0 );
790
636
}
791
637
792
- - (void )testPerformsAggregationWhenUsingArrayContainsAnyOperator {
793
- XCTSkipIf (![FSTIntegrationTestCase isRunningAgainstEmulator ],
794
- " Skip this test if running against production because it requires a composite index." );
795
-
796
- FIRCollectionReference* testCollection = [self collectionRefWithDocuments: @{
797
- @" a" : @{
798
- @" author" : @" authorA" ,
799
- @" title" : @" titleA" ,
800
- @" pages" : @100 ,
801
- @" year" : @1980 ,
802
- @" rating" : @[ @5 , @1000 ]
803
- },
804
- @" b" : @{
805
- @" author" : @" authorB" ,
806
- @" title" : @" titleB" ,
807
- @" pages" : @50 ,
808
- @" year" : @2020 ,
809
- @" rating" : @[ @4 ]
810
- },
811
- @" c" : @{
812
- @" author" : @" authorC" ,
813
- @" title" : @" titleC" ,
814
- @" pages" : @100 ,
815
- @" year" : @1980 ,
816
- @" rating" : @[ @2222 , @3 ]
817
- },
818
- @" d" : @{
819
- @" author" : @" authorD" ,
820
- @" title" : @" titleD" ,
821
- @" pages" : @50 ,
822
- @" year" : @2020 ,
823
- @" rating" : @[ @0 ]
824
- }
825
- }];
826
-
827
- FIRAggregateQuerySnapshot* snapshot = [self
828
- readSnapshotForAggregate: [[testCollection queryWhereField: @" rating"
829
- arrayContainsAny: @[ @5 , @3 ]]
830
- aggregate: @[
831
- [FIRAggregateField aggregateFieldForSumOfField: @" rating" ],
832
- [FIRAggregateField aggregateFieldForSumOfField: @" pages" ],
833
- [FIRAggregateField aggregateFieldForAverageOfField: @" rating" ],
834
- [FIRAggregateField aggregateFieldForAverageOfField: @" pages" ],
835
- [FIRAggregateField aggregateFieldForCount ]
836
- ]]];
837
-
838
- // Count
839
- XCTAssertEqual (
840
- [[snapshot valueForAggregateField: [FIRAggregateField aggregateFieldForCount ]] longValue ], 2L );
841
-
842
- // Sum
843
- XCTAssertEqual (
844
- [[snapshot valueForAggregateField: [FIRAggregateField aggregateFieldForSumOfField: @" rating" ]]
845
- longValue ],
846
- 0L );
847
- XCTAssertEqual (
848
- [[snapshot valueForAggregateField: [FIRAggregateField aggregateFieldForSumOfField: @" pages" ]]
849
- longValue ],
850
- 200L );
851
-
852
- // Average
853
- XCTAssertEqualObjects (
854
- [snapshot
855
- valueForAggregateField: [FIRAggregateField aggregateFieldForAverageOfField: @" rating" ]],
856
- [NSNull null ]);
857
- XCTAssertEqual (
858
- [[snapshot valueForAggregateField: [FIRAggregateField
859
- aggregateFieldForAverageOfField: @" pages" ]] doubleValue ],
860
- 100.0 );
861
- }
862
-
863
638
- (void )testPerformsAggregationsOnNestedMapValues {
864
639
FIRCollectionReference* testCollection = [self collectionRefWithDocuments: @{
865
640
@" a" : @{
0 commit comments