fix serverDownloader disposal. Correct linting errors

This commit is contained in:
Adam Hathcock
2025-05-21 13:35:21 +01:00
parent f8701d8cd3
commit fbd74dafe1
4 changed files with 23 additions and 4 deletions
@@ -12,7 +12,7 @@ describe('CachePump testing', () => {
const i2: Item = { baseId: 'id2', base: { id: 'id', speckle_type: 'type' } }
const gathered = new AsyncGeneratorQueue<Item>()
const deferments = new DefermentManager({ maxSize: 1, ttl: 1 })
const deferments = new DefermentManager({ maxSizeInMb: 1, ttlms: 1 })
const cachePump = new CachePump(new MemoryDatabase({}), gathered, deferments, {
maxCacheReadSize: 1,
maxCacheWriteSize: 1,
@@ -44,7 +44,7 @@ describe('CachePump testing', () => {
db.set(i2.baseId, i2.base)
const gathered = new AsyncGeneratorQueue<Item>()
const deferments = new DefermentManager({ maxSize: 1, ttl: 1 })
const deferments = new DefermentManager({ maxSizeInMb: 1, ttlms: 1 })
const cachePump = new CachePump(
new MemoryDatabase({ items: db }),
gathered,
@@ -8,7 +8,7 @@ describe('CacheReader testing', () => {
test('deferred getObject', async () => {
const i1: Item = { baseId: 'id1', base: { id: 'id', speckle_type: 'type' } }
const deferments = new DefermentManager({ maxSize: 1, ttl: 1 })
const deferments = new DefermentManager({ maxSizeInMb: 1, ttlms: 1 })
const cacheReader = new CacheReader(
new MemoryDatabase({
items: new Map<string, Base>([[i1.baseId, i1.base]])
@@ -27,6 +27,7 @@ describe('downloader', () => {
}
expect(r).toMatchSnapshot()
await downloader.disposeAsync()
})
test('download batch of two', async () => {
@@ -55,6 +56,7 @@ describe('downloader', () => {
}
expect(r).toMatchSnapshot()
await downloader.disposeAsync()
})
test('download batch of three', async () => {
@@ -90,6 +92,7 @@ describe('downloader', () => {
}
expect(r).toMatchSnapshot()
await downloader.disposeAsync()
})
test('download single exists', async () => {
@@ -109,6 +112,7 @@ describe('downloader', () => {
})
const x = await downloader.downloadSingle()
expect(x).toMatchSnapshot()
await downloader.disposeAsync()
})
test('add extra header', async () => {
@@ -134,5 +138,21 @@ describe('downloader', () => {
})
const x = await downloader.downloadSingle()
expect(x).toMatchSnapshot()
await downloader.disposeAsync()
})
test('can dispose used', async () => {
const fetchMocker = createFetchMock(vi)
const headers = new Headers()
const downloader = new ServerDownloader({
serverUrl: 'http://speckle.test',
headers,
streamId: 'streamId',
objectId: 'objectId',
token: 'token',
fetch: fetchMocker
})
await downloader.disposeAsync()
})
})
@@ -88,7 +88,6 @@ export default class ServerDownloader implements Downloader {
async disposeAsync(): Promise<void> {
await this.#downloadQueue?.disposeAsync()
await this.#getPool().disposeAsync()
}
#processJson(baseId: string, unparsedBase: string): Item {