Skip to content

Commit

Permalink
add test for attempting to add existing project
Browse files Browse the repository at this point in the history
  • Loading branch information
achou11 committed Aug 24, 2023
1 parent b520dbc commit 640a38e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test-e2e/manager-basic.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test } from 'brittle'
import { randomBytes } from 'crypto'
import { KeyManager } from '@mapeo/crypto'
import { MapeoManager } from '../src/mapeo-manager.js'
import { randomBytes } from 'crypto'

test('Managing multiple projects', async (t) => {
const manager = new MapeoManager({ rootKey: KeyManager.generateRootKey() })
Expand Down Expand Up @@ -33,3 +33,19 @@ test('Managing multiple projects', async (t) => {
'all created projects are listed'
)
})

test('Manager cannot add existing project', async (t) => {
const manager = new MapeoManager({ rootKey: KeyManager.generateRootKey() })

const existingProjectId = await manager.createProject()

t.exception(
manager.addProject({
projectKey: Buffer.from(existingProjectId, 'hex'),
encryptionKeys: {
auth: randomBytes(32),
},
}),
'attempting to add an existing project throws'
)
})

0 comments on commit 640a38e

Please sign in to comment.