-
Notifications
You must be signed in to change notification settings - Fork 923
Mila/bloom filter add integration test #7045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1615,30 +1615,34 @@ apiDescribe('Queries', (persistence: boolean) => { | |
}); | ||
}); | ||
}); | ||
|
||
it('can raise expected snapshot when resume query after deleting docs', () => { | ||
const testDocs = {}; | ||
for (let i = 1; i <= 100; i++) { | ||
Object.assign(testDocs, { ['doc' + i]: { key: i } }); | ||
} | ||
return withTestCollection(persistence, testDocs, async (coll, db) => { | ||
const snapshot1 = await getDocs(coll); | ||
expect(snapshot1.size).to.equal(100); | ||
// Delete 50 docs in transaction so that it doesn't affect local cache. | ||
await runTransaction(db, async txn => { | ||
for (let i = 1; i <= 50; i++) { | ||
txn.delete(doc(coll, 'doc' + i)); | ||
} | ||
|
||
// eslint-disable-next-line no-restricted-properties | ||
(persistence ? it.skip: it)( | ||
'can raise expected snapshot when resume query after deleting docs', | ||
() => { | ||
const testDocs = {}; | ||
for (let i = 1; i <= 100; i++) { | ||
Object.assign(testDocs, { ['doc' + i]: { key: i } }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can Object.assign(testDocs, { ['doc' + i]: { key: i } }) be simplified to testDocs['doc' + i] = { key: i } There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can convince TypeScript to be happy. Does this work: Change const testDocs = {}; to const testDocs: { [key: string]: Object } = {}; |
||
} | ||
return withTestCollection(persistence, testDocs, async (coll, db) => { | ||
const snapshot1 = await getDocs(coll); | ||
expect(snapshot1.size).to.equal(100); | ||
// Delete 50 docs in transaction so that it doesn't affect local cache. | ||
await runTransaction(db, async txn => { | ||
for (let i = 1; i <= 50; i++) { | ||
txn.delete(doc(coll, 'doc' + i)); | ||
} | ||
}); | ||
// Wait 10 seconds, during which the watch will stop tracking the query | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: "the watch" -> "Watch" (with a capital "W") |
||
// and will send an existence filter rather than "delete" events. | ||
await (function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can await (function () {
return new Promise(resolve => setTimeout(resolve, 10000));
})(); be simplified to await new Promise(resolve => setTimeout(resolve, 10000)); |
||
return new Promise(resolve => setTimeout(resolve, 10000)); | ||
})(); | ||
const snapshot2 = await getDocs(coll); | ||
expect(snapshot2.size).to.equal(50); | ||
}); | ||
// Wait 10 seconds, during which the watch will stop tracking the query | ||
// and will send an existence filter rather than "delete" events. | ||
await (function () { | ||
return new Promise(resolve => setTimeout(resolve, 10000)); | ||
})(); | ||
const snapshot2 = await getDocs(coll); | ||
expect(snapshot2.size).to.equal(50); | ||
}); | ||
}).timeout('15s'); | ||
} | ||
).timeout('20s'); | ||
}); | ||
|
||
function verifyDocumentChange<T>( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming this test to something like "resuming a query should remove deleted documents indicated by existence filter"