Skip to content

Commit

Permalink
additional test assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
achou11 committed Jan 11, 2024
1 parent 83df185 commit bc6246d
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions tests/core-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,8 @@ test('deleteData()', async (t) => {

const peer1TempPath = path.join(tempPath, 'peer1')

const db1 = drizzle(new Sqlite(':memory:'))

/// Set up core managers
const db1 = drizzle(new Sqlite(':memory:'))
const cm1 = createCoreManager({
db: db1,
projectKey,
Expand All @@ -480,7 +479,9 @@ test('deleteData()', async (t) => {
autoDownload: true,
})

const db2 = drizzle(new Sqlite(':memory:'))
const cm2 = createCoreManager({
db: db2,
projectKey,
storage: (name) => {
return new RandomAccessFile(path.join(tempPath, 'peer2', name))
Expand Down Expand Up @@ -554,6 +555,26 @@ test('deleteData()', async (t) => {
'peer 1 has expected number of data core storage files after replication'
)

t.is(
db1
.select()
.from(coresTable)
.where(eq(coresTable.namespace, 'data'))
.all().length,
1,
'peer 1 `cores` table has info about `data` core from peer 2'
)

t.is(
db2
.select()
.from(coresTable)
.where(eq(coresTable.namespace, 'data'))
.all().length,
1,
'peer 2 `cores` table has info about `data` core from peer 1'
)

/// Delete data (not their own)
await t.test('with deleteOwn=false or omitted', async (st) => {
await cm1.deleteData('data')
Expand Down

0 comments on commit bc6246d

Please sign in to comment.