Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

Commit

Permalink
fix: open store in tests (#66)
Browse files Browse the repository at this point in the history
Our compliance test suite closes the created stores during tear down
but doesn't open them during set up.

If we are responsible for closing stores we should be opening them too
which also gives us enough control to execute the lifecycle tests
properly.
  • Loading branch information
achingbrain authored Jan 22, 2021
1 parent cbbdd9e commit 6092b10
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ module.exports = (test) => {
await test.teardown()
}

const createStore = async () => {
const store = await test.setup()
if (!store) throw new Error('missing store')
await store.open()
return store
}

describe('put', () => {
/** @type {Datastore} */
let store

beforeEach(async () => {
store = await test.setup()
if (!store) throw new Error('missing store')
store = await createStore()
})

afterEach(() => cleanup(store))
Expand Down Expand Up @@ -61,8 +67,7 @@ module.exports = (test) => {
let store

beforeEach(async () => {
store = await test.setup()
if (!store) throw new Error('missing store')
store = await createStore()
})

afterEach(() => cleanup(store))
Expand Down Expand Up @@ -92,8 +97,7 @@ module.exports = (test) => {
let store

beforeEach(async () => {
store = await test.setup()
if (!store) throw new Error('missing store')
store = await createStore()
})

afterEach(() => cleanup(store))
Expand Down Expand Up @@ -124,8 +128,7 @@ module.exports = (test) => {
let store

beforeEach(async () => {
store = await test.setup()
if (!store) throw new Error('missing store')
store = await createStore()
})

afterEach(() => cleanup(store))
Expand Down Expand Up @@ -159,8 +162,7 @@ module.exports = (test) => {
let store

beforeEach(async () => {
store = await test.setup()
if (!store) throw new Error('missing store')
store = await createStore()
})

afterEach(() => cleanup(store))
Expand Down Expand Up @@ -198,8 +200,7 @@ module.exports = (test) => {
let store

beforeEach(async () => {
store = await test.setup()
if (!store) throw new Error('missing store')
store = await createStore()
})

afterEach(() => cleanup(store))
Expand Down Expand Up @@ -234,8 +235,7 @@ module.exports = (test) => {
let store

beforeEach(async () => {
store = await test.setup()
if (!store) throw new Error('missing store')
store = await createStore()
})

afterEach(() => cleanup(store))
Expand Down Expand Up @@ -342,8 +342,7 @@ module.exports = (test) => {
]

before(async () => {
store = await test.setup()
if (!store) throw new Error('missing store')
store = await createStore()

const b = store.batch()

Expand Down

0 comments on commit 6092b10

Please sign in to comment.