Skip to content

Commit 4ba3360

Browse files
committed
Fix tests
1 parent 341251c commit 4ba3360

File tree

2 files changed

+14
-48
lines changed

2 files changed

+14
-48
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,4 +1967,17 @@ apiDescribe('Database', persistence => {
19671967
});
19681968
});
19691969
});
1970+
1971+
it('Lru GC is enabled by default.', () => {
1972+
const initialData = { key: 'value' };
1973+
return withTestDb(persistence, async db => {
1974+
const docRef = doc(collection(db, 'test-collection'));
1975+
await setDoc(docRef, initialData);
1976+
return getDocFromCache(docRef).then(doc => {
1977+
expect(doc.exists()).to.be.true;
1978+
expect(doc.metadata.fromCache).to.be.true;
1979+
expect(doc.data()).to.deep.equal(initialData);
1980+
});
1981+
});
1982+
});
19701983
});

packages/firestore/test/integration/util/helpers.ts

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ function apiDescribeInternal(
181181
message: string,
182182
testSuite: (persistence: PersistenceMode) => void
183183
): void {
184-
const persistenceModes: PersistenceMode[] = [
185-
new MemoryEagerPersistenceMode()
186-
];
184+
const persistenceModes: PersistenceMode[] = [new MemoryLruPersistenceMode()];
187185
if (isPersistenceAvailable()) {
188186
persistenceModes.push(new IndexedDbPersistenceMode());
189187
}
@@ -254,51 +252,6 @@ export function withTestDb(
254252
});
255253
}
256254

257-
export function withEnsuredEagerGcTestDb(
258-
fn: (db: Firestore) => Promise<void>
259-
): Promise<void> {
260-
const newSettings = { ...DEFAULT_SETTINGS };
261-
newSettings.localCache = memoryLocalCache({
262-
garbageCollector: memoryEagerGarbageCollector()
263-
});
264-
return withTestDbsSettings(
265-
false,
266-
DEFAULT_PROJECT_ID,
267-
newSettings,
268-
1,
269-
async ([db]) => {
270-
return fn(db);
271-
}
272-
);
273-
}
274-
275-
export function withEnsuredLruGcTestDb(
276-
persistence: boolean,
277-
fn: (db: Firestore) => Promise<void>
278-
): Promise<void> {
279-
const newSettings = { ...DEFAULT_SETTINGS };
280-
if (persistence) {
281-
newSettings.localCache = persistentLocalCache({
282-
cacheSizeBytes: 1 * 1024 * 1024
283-
});
284-
} else {
285-
newSettings.localCache = memoryLocalCache({
286-
garbageCollector: memoryLruGarbageCollector({
287-
cacheSizeBytes: 1 * 1024 * 1024
288-
})
289-
});
290-
}
291-
return withTestDbsSettings(
292-
persistence,
293-
DEFAULT_PROJECT_ID,
294-
newSettings,
295-
1,
296-
async ([db]) => {
297-
return fn(db);
298-
}
299-
);
300-
}
301-
302255
/** Runs provided fn with a db for an alternate project id. */
303256
export function withAlternateTestDb(
304257
persistence: PersistenceMode | typeof PERSISTENCE_MODE_UNSPECIFIED,

0 commit comments

Comments
 (0)