Skip to content

Commit 384608c

Browse files
committed
cleanup
1 parent 01b3bf0 commit 384608c

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

packages/firestore/src/util/testing_hooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
* @internal
3333
*/
3434
export class TestingHooks {
35-
private readonly onExistenceFilterMismatchCallbacks: Map<
35+
private readonly onExistenceFilterMismatchCallbacks = new Map<
3636
Symbol,
3737
(arg: unknown) => void
38-
> = [];
38+
>();
3939

4040
private constructor() {}
4141

packages/firestore/test/integration/api/query.test.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,13 +2077,14 @@ apiDescribe('Queries', (persistence: boolean) => {
20772077

20782078
let attemptNumber = 0;
20792079
while (true) {
2080+
type IterationResult = 'retry' | 'passed';
20802081
attemptNumber++;
2081-
const bloomFilterApplied = await withTestCollection(
2082+
const iterationResult = await withTestCollection<IterationResult>(
20822083
persistence,
20832084
testDocs,
20842085
async (coll, db) => {
2085-
// Run a query to populate the local cache with the 100 documents and
2086-
// a resume token.
2086+
// Run a query to populate the local cache with the 100 documents
2087+
// and a resume token.
20872088
const snapshot1 = await getDocs(coll);
20882089
expect(snapshot1.size).to.equal(100);
20892090

@@ -2096,23 +2097,23 @@ apiDescribe('Queries', (persistence: boolean) => {
20962097
});
20972098

20982099
// Wait for 10 seconds, during which Watch will stop tracking the
2099-
// query and will send an existence filter rather than "delete" events
2100-
// when the query is resumed.
2100+
// query and will send an existence filter rather than "delete"
2101+
// events when the query is resumed.
21012102
await new Promise(resolve => setTimeout(resolve, 10000));
21022103

2103-
// Resume the query and expect to get a snapshot with the 50 remaining
2104-
// documents. Use some internal testing hooks to "capture" the
2105-
// existence filter mismatches to later verify that Watch sent a bloom
2106-
// filter, and it was used to void the full requery.
2104+
// Resume the query and expect to get a snapshot with the 50
2105+
// remaining documents. Use some internal testing hooks to "capture"
2106+
// the existence filter mismatches to later verify that Watch sent a
2107+
// bloom filter, and it was used to avert a full requery.
21072108
const existenceFilterMismatches =
21082109
await captureExistenceFilterMismatches(async () => {
21092110
const snapshot2 = await getDocs(coll);
21102111
expect(snapshot2.size).to.equal(50);
21112112
});
21122113

21132114
// Verify that upon resuming the query that Watch sent an existence
2114-
// filter that included a bloom filter, and that that bloom filter was
2115-
// successfully used to avoid a full requery.
2115+
// filter that included a bloom filter, and that that bloom filter
2116+
// was successfully used to avoid a full requery.
21162117
// TODO(b/NNNNNNNN) Replace this "if" condition with !USE_EMULATOR
21172118
// once the feature has been deployed to production. Note that there
21182119
// are no plans to implement the bloom filter in the existence filter
@@ -2134,7 +2135,7 @@ apiDescribe('Queries', (persistence: boolean) => {
21342135
// fail if the retry _also_ experiences a false positive.
21352136
if (!bloomFilter.applied) {
21362137
if (attemptNumber < 2) {
2137-
return false;
2138+
return 'retry';
21382139
} else {
21392140
expect.fail(
21402141
'bloom filter false positive occurred ' +
@@ -2150,11 +2151,12 @@ apiDescribe('Queries', (persistence: boolean) => {
21502151
expect(bloomFilter.padding).to.be.below(8);
21512152
}
21522153

2153-
return true;
2154+
return 'passed';
21542155
}
21552156
);
21562157

2157-
if (bloomFilterApplied) {
2158+
// Break out of the retry loop if the test passed.
2159+
if (iterationResult === 'passed') {
21582160
break;
21592161
}
21602162
}

0 commit comments

Comments
 (0)