Files
dolt/js/src/batch-store-test.js
T
Chris Masone 917a4d8564 JS: make sure we call close() on Database most of the time
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.
2016-05-19 16:49:54 -07:00

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();
});
});