/
branch.t.js
executable file
·38 lines (36 loc) · 1.34 KB
/
branch.t.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env node
require('./proof')(4, prove)
function prove (async, assert) {
var strata = createStrata({ directory: tmp, leafSize: 3, branchSize: 3 })
async(function () {
serialize(__dirname + '/fixtures/branch.before.json', tmp, async())
}, function () {
strata.open(async())
}, function () {
strata.mutator('n', async())
}, function (cursor) {
cursor.insert('n', 'n', ~cursor.index)
cursor.unlock(async())
}, function () {
gather(strata, async())
}, function (records) {
assert(records, [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n' ], 'records')
strata.balance(async())
}, function () {
vivify(tmp, async())
load(__dirname + '/fixtures/branch.after.json', async())
}, function (actual, expected) {
assert(actual, expected, 'split')
strata.purge(0)
assert(strata.sheaf.magazine.heft, 0, 'purge completely')
strata.close(async())
}, function () {
strata = createStrata({ directory: tmp, leafSize: 3, branchSize: 3 })
strata.open(async())
}, function () {
gather(strata, async())
}, function (records) {
assert(records, [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n' ], 'records')
strata.close(async())
})
}