mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-19 11:29:41 -05:00
917a4d8564
Other than DatasetSpec::value(), this should close all Database instances that we create. I'm not sure how to deal with that one case, though.
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
// @flow
|
|
|
|
import {suite, test} from 'mocha';
|
|
import {assert} from 'chai';
|
|
import MemoryStore from './memory-store.js';
|
|
import BatchStore from './batch-store.js';
|
|
import {BatchStoreAdaptorDelegate} from './batch-store-adaptor.js';
|
|
import {encodeNomsValue} from './encode.js';
|
|
|
|
suite('BatchStore', () => {
|
|
test('get after schedulePut works immediately', async () => {
|
|
const ms = new MemoryStore();
|
|
const bs = new BatchStore(3, new BatchStoreAdaptorDelegate(ms));
|
|
const input = 'abc';
|
|
|
|
const c = encodeNomsValue(input);
|
|
bs.schedulePut(c, new Set());
|
|
|
|
const chunk = await bs.get(c.ref);
|
|
assert.isTrue(c.ref.equals(chunk.ref));
|
|
await bs.close();
|
|
});
|
|
|
|
test('get after schedulePut works after flush', async () => {
|
|
const ms = new MemoryStore();
|
|
const bs = new BatchStore(3, new BatchStoreAdaptorDelegate(ms));
|
|
const input = 'abc';
|
|
|
|
const c = encodeNomsValue(input);
|
|
bs.schedulePut(c, new Set());
|
|
|
|
let chunk = await bs.get(c.ref);
|
|
assert.isTrue(c.ref.equals(chunk.ref));
|
|
|
|
await bs.flush();
|
|
chunk = await bs.get(c.ref);
|
|
assert.isTrue(c.ref.equals(chunk.ref));
|
|
await bs.close();
|
|
});
|
|
});
|