Skip to content

Commit 2110f36

Browse files
committed
serverTimestamp and integration tests
1 parent 748f6cf commit 2110f36

29 files changed

+4219
-455
lines changed

firebase-firestore/api.txt

Lines changed: 140 additions & 98 deletions
Large diffs are not rendered by default.

firebase-firestore/firebase-firestore.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ android {
7575
def targetBackend = findProperty("targetBackend") ?: "emulator"
7676
buildConfigField("String", "TARGET_BACKEND", "\"$targetBackend\"")
7777

78-
def targetDatabaseId = findProperty('targetDatabaseId') ?: "(default)"
78+
def targetDatabaseId = findProperty('targetDatabaseId') ?: "enterprise"
7979
buildConfigField("String", "TARGET_DATABASE_ID", "\"$targetDatabaseId\"")
8080

8181
def localProps = new Properties()

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/AggregationTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,12 @@ public void testCannotPerformMoreThanMaxAggregations() {
400400

401401
assertThat(e, instanceOf(FirebaseFirestoreException.class));
402402
FirebaseFirestoreException firestoreException = (FirebaseFirestoreException) e;
403-
assertEquals(FirebaseFirestoreException.Code.INVALID_ARGUMENT, firestoreException.getCode());
404-
assertTrue(firestoreException.getMessage().contains("maximum number of aggregations"));
403+
if (isRunningAgainstEmulator()) {
404+
assertEquals(FirebaseFirestoreException.Code.UNKNOWN, firestoreException.getCode());
405+
} else {
406+
assertEquals(FirebaseFirestoreException.Code.INVALID_ARGUMENT, firestoreException.getCode());
407+
assertTrue(firestoreException.getMessage().contains("maximum number of aggregations"));
408+
}
405409
}
406410

407411
@Test

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ConformanceTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import java.util.stream.Collectors;
4949
import org.junit.AfterClass;
5050
import org.junit.BeforeClass;
51+
import org.junit.Ignore;
5152
import org.junit.Test;
5253
import org.junit.runner.RunWith;
5354
import org.junit.runners.Parameterized;
@@ -61,6 +62,7 @@
6162
* com.google.firebase.firestore.conformance}) were modified to support the Android SDK.
6263
*/
6364
@RunWith(Parameterized.class)
65+
@Ignore
6466
public class ConformanceTest {
6567
private static FirebaseFirestore firestore;
6668
private static TestCaseIgnoreList testCaseIgnoreList;

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/PipelineTest.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.google.firebase.firestore.pipeline.Expr.and;
2020
import static com.google.firebase.firestore.pipeline.Expr.arrayContains;
2121
import static com.google.firebase.firestore.pipeline.Expr.arrayContainsAny;
22+
import static com.google.firebase.firestore.pipeline.Expr.constant;
2223
import static com.google.firebase.firestore.pipeline.Expr.cosineDistance;
2324
import static com.google.firebase.firestore.pipeline.Expr.endsWith;
2425
import static com.google.firebase.firestore.pipeline.Expr.eq;
@@ -37,6 +38,7 @@
3738
import static com.google.firebase.firestore.pipeline.Expr.subtract;
3839
import static com.google.firebase.firestore.pipeline.Expr.vector;
3940
import static com.google.firebase.firestore.pipeline.Ordering.ascending;
41+
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.isRunningAgainstEmulator;
4042
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
4143

4244
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -47,6 +49,7 @@
4749
import com.google.firebase.firestore.pipeline.AggregateFunction;
4850
import com.google.firebase.firestore.pipeline.AggregateStage;
4951
import com.google.firebase.firestore.pipeline.Expr;
52+
import com.google.firebase.firestore.pipeline.Field;
5053
import com.google.firebase.firestore.pipeline.RawStage;
5154
import com.google.firebase.firestore.testutil.IntegrationTestUtil;
5255
import java.util.Collections;
@@ -367,13 +370,14 @@ public void whereWithOr() {
367370
.collection(randomCol)
368371
.where(or(eq("genre", "Romance"), eq("genre", "Dystopian")))
369372
.select("title")
373+
.sort(field("title").ascending())
370374
.execute();
371375
assertThat(waitFor(execute).getResults())
372376
.comparingElementsUsing(DATA_CORRESPONDENCE)
373377
.containsExactly(
378+
ImmutableMap.of("title", "1984"),
374379
ImmutableMap.of("title", "Pride and Prejudice"),
375-
ImmutableMap.of("title", "The Handmaid's Tale"),
376-
ImmutableMap.of("title", "1984"));
380+
ImmutableMap.of("title", "The Handmaid's Tale"));
377381
}
378382

379383
@Test
@@ -418,6 +422,7 @@ public void arrayContainsAnyWorks() {
418422
.collection(randomCol)
419423
.where(arrayContainsAny("tags", ImmutableList.of("comedy", "classic")))
420424
.select("title")
425+
.sort(field("title").descending())
421426
.execute();
422427
assertThat(waitFor(execute).getResults())
423428
.comparingElementsUsing(DATA_CORRESPONDENCE)
@@ -480,7 +485,8 @@ public void testStrConcat() {
480485
firestore
481486
.pipeline()
482487
.collection(randomCol)
483-
.select(field("author").strConcat(" - ", field("title")).alias("bookInfo"))
488+
.sort(ascending(Field.DOCUMENT_ID))
489+
.select(strConcat(field("author"), constant(" - "), field("title")).alias("bookInfo"))
484490
.limit(1)
485491
.execute();
486492
assertThat(waitFor(execute).getResults())
@@ -545,12 +551,12 @@ public void testLength() {
545551
}
546552

547553
@Test
548-
@Ignore("Not supported yet")
549554
public void testToLowercase() {
550555
Task<PipelineSnapshot> execute =
551556
firestore
552557
.pipeline()
553558
.collection(randomCol)
559+
.sort(Field.DOCUMENT_ID.ascending())
554560
.select(field("title").toLower().alias("lowercaseTitle"))
555561
.limit(1)
556562
.execute();
@@ -560,12 +566,12 @@ public void testToLowercase() {
560566
}
561567

562568
@Test
563-
@Ignore("Not supported yet")
564569
public void testToUppercase() {
565570
Task<PipelineSnapshot> execute =
566571
firestore
567572
.pipeline()
568573
.collection(randomCol)
574+
.sort(Field.DOCUMENT_ID.ascending())
569575
.select(field("author").toUpper().alias("uppercaseAuthor"))
570576
.limit(1)
571577
.execute();
@@ -597,6 +603,10 @@ public void testTrim() {
597603

598604
@Test
599605
public void testLike() {
606+
if (isRunningAgainstEmulator()) {
607+
return;
608+
}
609+
600610
Task<PipelineSnapshot> execute =
601611
firestore
602612
.pipeline()
@@ -611,6 +621,10 @@ public void testLike() {
611621

612622
@Test
613623
public void testRegexContains() {
624+
if (isRunningAgainstEmulator()) {
625+
return;
626+
}
627+
614628
Task<PipelineSnapshot> execute =
615629
firestore
616630
.pipeline()
@@ -622,6 +636,10 @@ public void testRegexContains() {
622636

623637
@Test
624638
public void testRegexMatches() {
639+
if (isRunningAgainstEmulator()) {
640+
return;
641+
}
642+
625643
Task<PipelineSnapshot> execute =
626644
firestore
627645
.pipeline()
@@ -637,12 +655,13 @@ public void testArithmeticOperations() {
637655
firestore
638656
.pipeline()
639657
.collection(randomCol)
658+
.sort(ascending(Field.DOCUMENT_ID))
659+
.limit(1)
640660
.select(
641661
add(field("rating"), 1).alias("ratingPlusOne"),
642662
subtract(field("published"), 1900).alias("yearsSince1900"),
643663
field("rating").multiply(10).alias("ratingTimesTen"),
644664
field("rating").divide(2).alias("ratingDividedByTwo"))
645-
.limit(1)
646665
.execute();
647666
assertThat(waitFor(execute).getResults())
648667
.comparingElementsUsing(DATA_CORRESPONDENCE)
@@ -749,6 +768,7 @@ public void testMapGet() {
749768
firestore
750769
.pipeline()
751770
.collection(randomCol)
771+
.sort(field("title").descending())
752772
.select(field("awards").mapGet("hugo").alias("hugoAward"), field("title"))
753773
.where(eq("hugoAward", true))
754774
.execute();
@@ -790,6 +810,7 @@ public void testNestedFields() {
790810
.collection(randomCol)
791811
.where(eq("awards.hugo", true))
792812
.select("title", "awards.hugo")
813+
.sort(field("title").descending())
793814
.execute();
794815
assertThat(waitFor(execute).getResults())
795816
.comparingElementsUsing(DATA_CORRESPONDENCE)
@@ -805,6 +826,7 @@ public void testMapGetWithFieldNameIncludingNotation() {
805826
.pipeline()
806827
.collection(randomCol)
807828
.where(eq("awards.hugo", true))
829+
.sort(field("title").descending())
808830
.select(
809831
"title",
810832
field("nestedField.level.1"),

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/QueryToPipelineTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testCollectionWithDocs;
2929
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.testFirestore;
3030
import static com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor;
31+
import static com.google.firebase.firestore.testutil.TestUtil.expectError;
32+
import static com.google.firebase.firestore.testutil.TestUtil.map;
3133
import static java.util.Arrays.asList;
3234
import static java.util.Collections.singletonList;
3335
import static org.junit.Assert.assertEquals;

0 commit comments

Comments
 (0)