Skip to content

Commit

Permalink
teardown bases that use tmpDir
Browse files Browse the repository at this point in the history
  • Loading branch information
chm-diederichs committed Feb 14, 2024
1 parent e2034e0 commit 7ca37f1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/fast-forward.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ test('fast-forward - simple', async t => {

await b.ready()

t.teardown(() => Promise.all([
a.close(),
b.close()
]))

for (let i = 0; i < 1000; i++) {
await a.append('a' + i)
}
Expand All @@ -72,6 +77,12 @@ test('fast-forward - migrate', async t => {
storage: () => tmpDir(t)
})

t.teardown(() => Promise.all([
a.close(),
b.close(),
c.close()
]))

for (let i = 0; i < 2000; i++) {
await a.append('a' + i)
}
Expand Down Expand Up @@ -103,6 +114,12 @@ test('fast-forward - fast forward after migrate', async t => {
storage: () => tmpDir(t)
})

t.teardown(() => Promise.all([
a.close(),
b.close(),
c.close()
]))

for (let i = 0; i < 2000; i++) {
await a.append('a' + i)
}
Expand Down Expand Up @@ -156,6 +173,13 @@ test('fast-forward - multiple writers added', async t => {
storage: () => tmpDir(t)
})

t.teardown(() => Promise.all([
a.close(),
b.close(),
c.close(),
d.close()
]))

await addWriterAndSync(a, b)
await addWriterAndSync(a, c)

Expand Down Expand Up @@ -208,6 +232,13 @@ test('fast-forward - multiple queues', async t => {
storage: () => tmpDir(t)
})

t.teardown(() => Promise.all([
a.close(),
b.close(),
c.close(),
d.close()
]))

// this value should be long enough that 2 fast-forwards are
// queued (ie. we don't just replicate the last state), but short
// enough that the second is queued before the first has completed
Expand Down Expand Up @@ -305,6 +336,11 @@ test('fast-forward - open with no remote io', async t => {

await b.ready()

t.teardown(() => Promise.all([
a.close(),
b.close()
]))

for (let i = 0; i < 1000; i++) {
await a.append('a' + i)
}
Expand Down Expand Up @@ -381,6 +417,12 @@ test('fast-forward - force reset then ff', async t => {
storage: () => tmpDir(t)
})

t.teardown(() => Promise.all([
a.close(),
b.close(),
c.close()
]))

await addWriterAndSync(a, b)
await addWriterAndSync(a, c)
await confirm([a, b, c])
Expand Down
5 changes: 5 additions & 0 deletions test/suspend.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ test('suspend - pass exisiting fs store', async t => {
const base3 = new Autobase(session3, base1.local.key, { apply, valueEncoding: 'json', ackInterval: 0, ackThreshold: 0, fastForward: false })
await base3.ready()

t.teardown(() => Promise.all([
base1.close(),
base3.close()
])

t.is(base3.activeWriters.size, 2)

await base3.append('final')
Expand Down

0 comments on commit 7ca37f1

Please sign in to comment.