-
Notifications
You must be signed in to change notification settings - Fork 3
/
localAgent.test.ts
45 lines (34 loc) · 1.06 KB
/
localAgent.test.ts
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
39
40
41
42
43
44
45
import { getConfig } from '@veramo/cli/build/setup'
import { createObjects } from '@veramo/cli/build/lib/objectCreator'
import { DataSource } from 'typeorm'
import fs from 'fs'
import { jest } from '@jest/globals'
jest.setTimeout(30000)
// Shared tests
import myPluginLogic from './shared/myPluginLogic'
import myPluginEventsLogic from './shared/myPluginEventsLogic'
let dbConnection: DataSource
let agent: any
const setup = async (): Promise<boolean> => {
const config = await getConfig('./agent.yml')
const { localAgent, db } = await createObjects(config, { localAgent: '/agent', db: '/dbConnection' })
agent = localAgent
dbConnection = db
return true
}
const tearDown = async (): Promise<boolean> => {
try {
await dbConnection.dropDatabase()
await dbConnection.destroy()
fs.unlinkSync('./database.sqlite')
} catch (e: any) {
// nop
}
return true
}
const getAgent = () => agent
const testContext = { getAgent, setup, tearDown }
describe('Local integration tests', () => {
myPluginLogic(testContext)
myPluginEventsLogic(testContext)
})