Skip to content

Commit d6fafba

Browse files
committed
Makes sure SDK still works after loading bad bundles.
1 parent 556a007 commit d6fafba

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,31 @@ apiDescribe('Bundles', (persistence: boolean) => {
226226

227227
it('load with documents from other projects fails.', () => {
228228
return withTestDb(persistence, async db => {
229-
const builder = bundleWithTestDocs(db);
229+
let builder = bundleWithTestDocs(db);
230230
return withAlternateTestDb(persistence, async otherDb => {
231231
// eslint-disable-next-line @typescript-eslint/no-floating-promises
232232
expect(
233233
otherDb.loadBundle(
234234
builder.build('test-bundle', { seconds: 1001, nanos: 9999 })
235235
)
236236
).to.be.rejectedWith('Tried to deserialize key from different project');
237+
238+
// Verify otherDb still functions, despite loaded a problematic bundle.
239+
builder = bundleWithTestDocs(otherDb);
240+
const progress = await otherDb.loadBundle(
241+
builder.build('test-bundle', { seconds: 1001, nanos: 9999 })
242+
);
243+
verifySuccessProgress(progress);
244+
245+
// Read from cache. These documents do not exist in backend, so they can
246+
// only be read from cache.
247+
const snap = await otherDb
248+
.collection('coll-1')
249+
.get({ source: 'cache' });
250+
expect(toDataArray(snap)).to.deep.equal([
251+
{ k: 'a', bar: 1 },
252+
{ k: 'b', bar: 2 }
253+
]);
237254
});
238255
});
239256
});

0 commit comments

Comments
 (0)