@credo-ts/drizzle-storage 0.6.0-pr-2324-20250708123651 → 0.6.0-pr-2324-20250709075226

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,7 @@ if (drizzleDialect === 'sqlite') {
48
48
  dbCredentials: { url: drizzleDatabaseUrl },
49
49
  }
50
50
  : {
51
- driver: 'pglite',
51
+ driver: 'node-postgres',
52
52
  }),
53
53
  })
54
54
  }
@@ -46,7 +46,7 @@ else {
46
46
  dbCredentials: { url: drizzleDatabaseUrl },
47
47
  }
48
48
  : {
49
- driver: 'pglite',
49
+ driver: 'node-postgres',
50
50
  }),
51
51
  });
52
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"drizzle.config.js","sourceRoot":"","sources":["../cli/drizzle.config.ts"],"names":[],"mappings":";;AAAA,6CAAkD;AAElD,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;AAE3D,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAA;AAClD,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,KAAK,QAAQ,IAAI,cAAc,KAAK,UAAU,CAAC,EAAE,CAAC;IACtF,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAA;AACnG,CAAC;AAED,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAA;AACzD,MAAM,uBAAuB,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAA;AACrE,MAAM,sBAAsB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAA;AAEnE,IAAI,aAAqB,CAAA;AAEzB,IAAI,cAAc,KAAK,QAAQ,EAAE,CAAC;IAChC,aAAa,GAAG,IAAA,0BAAY,EAAC;QAC3B,OAAO,EAAE,cAAc;QACvB,gFAAgF;QAChF,gEAAgE;QAChE,MAAM,EAAE,iBAAiB;QACzB,GAAG,EAAE,uBAAuB;QAC5B,UAAU,EAAE,sBAAsB;YAChC,CAAC,CAAC;gBACE,KAAK,EAAE,sBAAsB;aAC9B;YACH,CAAC,CAAC,SAAS;QACb,GAAG,CAAC,kBAAkB;YACpB,CAAC,CAAC;gBACE,aAAa,EAAE,EAAE,GAAG,EAAE,kBAAkB,EAAE;aAC3C;YACH,CAAC,CAAC;gBACE,MAAM,EAAE,MAAM;aACf,CAAC;KACP,CAAC,CAAA;AACJ,CAAC;KAAM,CAAC;IACN,aAAa,GAAG,IAAA,0BAAY,EAAC;QAC3B,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,iBAAiB;QACzB,GAAG,EAAE,uBAAuB;QAC5B,UAAU,EAAE,sBAAsB;YAChC,CAAC,CAAC;gBACE,KAAK,EAAE,sBAAsB;aAC9B;YACH,CAAC,CAAC,SAAS;QACb,GAAG,CAAC,kBAAkB;YACpB,CAAC,CAAC;gBACE,aAAa,EAAE,EAAE,GAAG,EAAE,kBAAkB,EAAE;aAC3C;YACH,CAAC,CAAC;gBACE,MAAM,EAAE,QAAQ;aACjB,CAAC;KACP,CAAC,CAAA;AACJ,CAAC;AAED,kBAAe,aAAa,CAAA"}
1
+ {"version":3,"file":"drizzle.config.js","sourceRoot":"","sources":["../cli/drizzle.config.ts"],"names":[],"mappings":";;AAAA,6CAAkD;AAElD,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;AAE3D,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAA;AAClD,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,KAAK,QAAQ,IAAI,cAAc,KAAK,UAAU,CAAC,EAAE,CAAC;IACtF,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAA;AACnG,CAAC;AAED,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAA;AACzD,MAAM,uBAAuB,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAA;AACrE,MAAM,sBAAsB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAA;AAEnE,IAAI,aAAqB,CAAA;AAEzB,IAAI,cAAc,KAAK,QAAQ,EAAE,CAAC;IAChC,aAAa,GAAG,IAAA,0BAAY,EAAC;QAC3B,OAAO,EAAE,cAAc;QACvB,gFAAgF;QAChF,gEAAgE;QAChE,MAAM,EAAE,iBAAiB;QACzB,GAAG,EAAE,uBAAuB;QAC5B,UAAU,EAAE,sBAAsB;YAChC,CAAC,CAAC;gBACE,KAAK,EAAE,sBAAsB;aAC9B;YACH,CAAC,CAAC,SAAS;QACb,GAAG,CAAC,kBAAkB;YACpB,CAAC,CAAC;gBACE,aAAa,EAAE,EAAE,GAAG,EAAE,kBAAkB,EAAE;aAC3C;YACH,CAAC,CAAC;gBACE,MAAM,EAAE,MAAM;aACf,CAAC;KACP,CAAC,CAAA;AACJ,CAAC;KAAM,CAAC;IACN,aAAa,GAAG,IAAA,0BAAY,EAAC;QAC3B,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,iBAAiB;QACzB,GAAG,EAAE,uBAAuB;QAC5B,UAAU,EAAE,sBAAsB;YAChC,CAAC,CAAC;gBACE,KAAK,EAAE,sBAAsB;aAC9B;YACH,CAAC,CAAC,SAAS;QACb,GAAG,CAAC,kBAAkB;YACpB,CAAC,CAAC;gBACE,aAAa,EAAE,EAAE,GAAG,EAAE,kBAAkB,EAAE;aAC3C;YACH,CAAC,CAAC;gBACE,MAAM,EAAE,eAAe;aACxB,CAAC;KACP,CAAC,CAAA;AACJ,CAAC;AAED,kBAAe,aAAa,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credo-ts/drizzle-storage",
3
- "version": "0.6.0-pr-2324-20250708123651",
3
+ "version": "0.6.0-pr-2324-20250709075226",
4
4
  "files": [
5
5
  "build",
6
6
  "cli-build",
@@ -52,24 +52,24 @@
52
52
  "ts-node": "^10.9.2",
53
53
  "tsyringe": "^4.8.0",
54
54
  "zod": "^3.24.2",
55
- "@credo-ts/action-menu": "0.6.0-pr-2324-20250708123651",
56
- "@credo-ts/anoncreds": "0.6.0-pr-2324-20250708123651",
57
- "@credo-ts/core": "0.6.0-pr-2324-20250708123651",
58
- "@credo-ts/didcomm": "0.6.0-pr-2324-20250708123651",
59
- "@credo-ts/drpc": "0.6.0-pr-2324-20250708123651",
60
- "@credo-ts/openid4vc": "0.6.0-pr-2324-20250708123651",
61
- "@credo-ts/question-answer": "0.6.0-pr-2324-20250708123651",
62
- "@credo-ts/tenants": "0.6.0-pr-2324-20250708123651"
55
+ "@credo-ts/action-menu": "0.6.0-pr-2324-20250709075226",
56
+ "@credo-ts/anoncreds": "0.6.0-pr-2324-20250709075226",
57
+ "@credo-ts/core": "0.6.0-pr-2324-20250709075226",
58
+ "@credo-ts/didcomm": "0.6.0-pr-2324-20250709075226",
59
+ "@credo-ts/drpc": "0.6.0-pr-2324-20250709075226",
60
+ "@credo-ts/openid4vc": "0.6.0-pr-2324-20250709075226",
61
+ "@credo-ts/question-answer": "0.6.0-pr-2324-20250709075226",
62
+ "@credo-ts/tenants": "0.6.0-pr-2324-20250709075226"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "drizzle-orm": "^0.44.2"
66
66
  },
67
67
  "devDependencies": {
68
- "@electric-sql/pglite": "^0.3.1",
69
68
  "@libsql/client": "^0.15.6",
69
+ "@types/pg": "^8.15.4",
70
70
  "@types/yargs": "^17.0.33",
71
- "pg": "^8.16.3",
72
71
  "drizzle-orm": "^0.44.2",
72
+ "pg": "^8.16.3",
73
73
  "rimraf": "^4.4.0",
74
74
  "typescript": "~5.5.2"
75
75
  },
@@ -84,6 +84,6 @@
84
84
  "cli:dev:migrate:sqlite": "pnpm cli:dev migrate --dialect sqlite --database-url \"file:local.db\"",
85
85
  "cli:dev:studio:postgres": "pnpm cli:dev studio --dialect postgres --database-url \"postgresql://postgres:postgres@localhost:5432/postgres\"",
86
86
  "cli:dev:studio:sqlite": "pnpm cli:dev studio --dialect sqlite --database-url \"file:local.db\"",
87
- "test": "NODE_OPTIONS=--experimental-vm-modules jest"
87
+ "test": "jest"
88
88
  }
89
89
  }
@@ -1,8 +1,6 @@
1
1
  import { ConnectionRecord, DidExchangeRole, DidExchangeState } from '@credo-ts/didcomm'
2
2
  import { pushSchema } from 'drizzle-kit/api'
3
- import { PgDatabase } from 'drizzle-orm/pg-core'
4
- import { drizzle } from 'drizzle-orm/pglite'
5
- import { DrizzlePostgresDatabase } from '../../DrizzleDatabase'
3
+ import { DrizzlePostgresTestDatabase, createDrizzlePostgresTestDatabase } from '../../../tests/testDatabase'
6
4
  import * as coreContextSchema from '../../core/context/postgres'
7
5
  import * as didcommConnectionSchema from '../../didcomm/connection/postgres'
8
6
  import { queryToDrizzlePostgres } from '../queryToDrizzlePostgres'
@@ -10,23 +8,23 @@ import { queryToDrizzlePostgres } from '../queryToDrizzlePostgres'
10
8
  const { didcommConnection } = didcommConnectionSchema
11
9
  const { context } = coreContextSchema
12
10
 
13
- const db = drizzle('memory://', {
14
- schema: { ...didcommConnectionSchema, ...coreContextSchema },
15
- }) as unknown as DrizzlePostgresDatabase<typeof didcommConnectionSchema>
16
-
17
11
  describe('queryToDrizzlePostgres', () => {
12
+ let postgresDatabase: DrizzlePostgresTestDatabase
13
+
18
14
  beforeAll(async () => {
15
+ postgresDatabase = await createDrizzlePostgresTestDatabase()
16
+
19
17
  const { apply } = await pushSchema(
20
18
  { ...didcommConnectionSchema, ...coreContextSchema },
21
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
22
- db as unknown as PgDatabase<any>
19
+ // @ts-ignore
20
+ postgresDatabase.drizzle
23
21
  )
24
22
  await apply()
25
23
 
26
- await db.insert(context).values({
24
+ await postgresDatabase.drizzle.insert(context).values({
27
25
  contextCorrelationId: 'b2fc0867-d0d1-4182-ade7-813b695d43c2',
28
26
  })
29
- await db.insert(didcommConnection).values({
27
+ await postgresDatabase.drizzle.insert(didcommConnection).values({
30
28
  createdAt: new Date(),
31
29
  updatedAt: new Date(),
32
30
  contextCorrelationId: 'b2fc0867-d0d1-4182-ade7-813b695d43c2',
@@ -42,9 +40,13 @@ describe('queryToDrizzlePostgres', () => {
42
40
  })
43
41
  })
44
42
 
43
+ afterAll(async () => {
44
+ await postgresDatabase.teardown()
45
+ })
46
+
45
47
  test('should correctly query column', async () => {
46
48
  expect(
47
- await db
49
+ await postgresDatabase.drizzle
48
50
  .select()
49
51
  .from(didcommConnection)
50
52
  .where(
@@ -58,7 +60,7 @@ describe('queryToDrizzlePostgres', () => {
58
60
  ).toHaveLength(1)
59
61
 
60
62
  expect(
61
- await db
63
+ await postgresDatabase.drizzle
62
64
  .select()
63
65
  .from(didcommConnection)
64
66
  .where(
@@ -74,7 +76,7 @@ describe('queryToDrizzlePostgres', () => {
74
76
 
75
77
  test('should correctly query array value column', async () => {
76
78
  expect(
77
- await db
79
+ await postgresDatabase.drizzle
78
80
  .select()
79
81
  .from(didcommConnection)
80
82
  .where(
@@ -89,7 +91,7 @@ describe('queryToDrizzlePostgres', () => {
89
91
  ).toHaveLength(1)
90
92
 
91
93
  expect(
92
- await db
94
+ await postgresDatabase.drizzle
93
95
  .select()
94
96
  .from(didcommConnection)
95
97
  .where(
@@ -104,7 +106,7 @@ describe('queryToDrizzlePostgres', () => {
104
106
  ).toHaveLength(0)
105
107
 
106
108
  expect(
107
- await db
109
+ await postgresDatabase.drizzle
108
110
  .select()
109
111
  .from(didcommConnection)
110
112
  .where(
@@ -121,7 +123,7 @@ describe('queryToDrizzlePostgres', () => {
121
123
 
122
124
  test('should correctly query custom tag column value', async () => {
123
125
  expect(
124
- await db
126
+ await postgresDatabase.drizzle
125
127
  .select()
126
128
  .from(didcommConnection)
127
129
  .where(
@@ -136,7 +138,7 @@ describe('queryToDrizzlePostgres', () => {
136
138
  ).toHaveLength(1)
137
139
 
138
140
  expect(
139
- await db
141
+ await postgresDatabase.drizzle
140
142
  .select()
141
143
  .from(didcommConnection)
142
144
  .where(
@@ -153,7 +155,7 @@ describe('queryToDrizzlePostgres', () => {
153
155
 
154
156
  test('should correctly query custom tag column array value', async () => {
155
157
  expect(
156
- await db
158
+ await postgresDatabase.drizzle
157
159
  .select()
158
160
  .from(didcommConnection)
159
161
  .where(
@@ -168,7 +170,7 @@ describe('queryToDrizzlePostgres', () => {
168
170
  ).toHaveLength(1)
169
171
 
170
172
  expect(
171
- await db
173
+ await postgresDatabase.drizzle
172
174
  .select()
173
175
  .from(didcommConnection)
174
176
  .where(
@@ -183,7 +185,7 @@ describe('queryToDrizzlePostgres', () => {
183
185
  ).toHaveLength(0)
184
186
 
185
187
  expect(
186
- await db
188
+ await postgresDatabase.drizzle
187
189
  .select()
188
190
  .from(didcommConnection)
189
191
  .where(
@@ -200,7 +202,7 @@ describe('queryToDrizzlePostgres', () => {
200
202
 
201
203
  test('should correctly query with and/or', async () => {
202
204
  expect(
203
- await db
205
+ await postgresDatabase.drizzle
204
206
  .select()
205
207
  .from(didcommConnection)
206
208
  .where(
@@ -227,7 +229,7 @@ describe('queryToDrizzlePostgres', () => {
227
229
  ).toHaveLength(1)
228
230
 
229
231
  expect(
230
- await db
232
+ await postgresDatabase.drizzle
231
233
  .select()
232
234
  .from(didcommConnection)
233
235
  .where(
@@ -259,7 +261,7 @@ describe('queryToDrizzlePostgres', () => {
259
261
 
260
262
  test('should correctly query with not', async () => {
261
263
  expect(
262
- await db
264
+ await postgresDatabase.drizzle
263
265
  .select()
264
266
  .from(didcommConnection)
265
267
  .where(
@@ -291,7 +293,7 @@ describe('queryToDrizzlePostgres', () => {
291
293
  ).toHaveLength(1)
292
294
 
293
295
  expect(
294
- await db
296
+ await postgresDatabase.drizzle
295
297
  .select()
296
298
  .from(didcommConnection)
297
299
  .where(
@@ -1,14 +1,18 @@
1
1
  import { AnonCredsSchemaRecord, AnonCredsSchemaRepository } from '@credo-ts/anoncreds'
2
- import { Agent, JsonTransformer } from '@credo-ts/core'
2
+ import { JsonTransformer } from '@credo-ts/core'
3
3
 
4
- import { setupDrizzleRecordTest } from '../../../../tests/testDatabase'
4
+ import { DrizzleRecordTest, setupDrizzleRecordTest } from '../../../../tests/testDatabase'
5
5
  import { anonCredsSchemaDrizzleRecord } from '../index'
6
6
 
7
7
  describe.each(['postgres', 'sqlite'] as const)('AnonCredsSchemaRecord with %s', (type) => {
8
- let agent: Agent
8
+ let recordTest: DrizzleRecordTest
9
9
 
10
10
  beforeAll(async () => {
11
- agent = await setupDrizzleRecordTest(type, anonCredsSchemaDrizzleRecord)
11
+ recordTest = await setupDrizzleRecordTest(type, anonCredsSchemaDrizzleRecord)
12
+ })
13
+
14
+ afterAll(async () => {
15
+ await recordTest.teardown()
12
16
  })
13
17
 
14
18
  test('create, retrieve, update, query and delete schema record', async () => {
@@ -28,20 +32,20 @@ describe.each(['postgres', 'sqlite'] as const)('AnonCredsSchemaRecord with %s',
28
32
  },
29
33
  AnonCredsSchemaRecord
30
34
  )
31
- const anoncredsSchemaRepository = agent.context.resolve(AnonCredsSchemaRepository)
35
+ const anoncredsSchemaRepository = recordTest.agent.context.resolve(AnonCredsSchemaRepository)
32
36
 
33
- await anoncredsSchemaRepository.save(agent.context, schema)
37
+ await anoncredsSchemaRepository.save(recordTest.agent.context, schema)
34
38
 
35
- const schema2 = await anoncredsSchemaRepository.findById(agent.context, schema.id)
39
+ const schema2 = await anoncredsSchemaRepository.findById(recordTest.agent.context, schema.id)
36
40
  expect(schema).toEqual(schema2)
37
41
 
38
42
  schema.setTags({
39
43
  myCustomTag: 'hello',
40
44
  isMorning: false,
41
45
  })
42
- await anoncredsSchemaRepository.update(agent.context, schema)
46
+ await anoncredsSchemaRepository.update(recordTest.agent.context, schema)
43
47
 
44
- const [schema3] = await anoncredsSchemaRepository.findByQuery(agent.context, {
48
+ const [schema3] = await anoncredsSchemaRepository.findByQuery(recordTest.agent.context, {
45
49
  // TODO: we should allow null values in the query
46
50
  // unqualifiedSchemaId: null,
47
51
  isMorning: false,
@@ -54,13 +58,13 @@ describe.each(['postgres', 'sqlite'] as const)('AnonCredsSchemaRecord with %s',
54
58
  expect(schema3).toEqual(schema)
55
59
 
56
60
  expect(
57
- await anoncredsSchemaRepository.findByQuery(agent.context, {
61
+ await anoncredsSchemaRepository.findByQuery(recordTest.agent.context, {
58
62
  myCustomTag: 'not-hello',
59
63
  })
60
64
  ).toHaveLength(0)
61
65
 
62
- await anoncredsSchemaRepository.deleteById(agent.context, schema.id)
66
+ await anoncredsSchemaRepository.deleteById(recordTest.agent.context, schema.id)
63
67
 
64
- expect(await anoncredsSchemaRepository.findByQuery(agent.context, {})).toHaveLength(0)
68
+ expect(await anoncredsSchemaRepository.findByQuery(recordTest.agent.context, {})).toHaveLength(0)
65
69
  })
66
70
  })
@@ -1,4 +1,4 @@
1
- import { Agent, JsonTransformer } from '@credo-ts/core'
1
+ import { JsonTransformer } from '@credo-ts/core'
2
2
 
3
3
  import {
4
4
  AutoAcceptCredential,
@@ -7,14 +7,18 @@ import {
7
7
  CredentialRole,
8
8
  CredentialState,
9
9
  } from '@credo-ts/didcomm'
10
- import { setupDrizzleRecordTest } from '../../../../tests/testDatabase'
10
+ import { DrizzleRecordTest, setupDrizzleRecordTest } from '../../../../tests/testDatabase'
11
11
  import { didcommCredentialExchangeDrizzleRecord } from '../index'
12
12
 
13
13
  describe.each(['postgres', 'sqlite'] as const)('CredentialExchangeRecord with %s', (type) => {
14
- let agent: Agent
14
+ let recordTest: DrizzleRecordTest
15
15
 
16
16
  beforeAll(async () => {
17
- agent = await setupDrizzleRecordTest(type, didcommCredentialExchangeDrizzleRecord)
17
+ recordTest = await setupDrizzleRecordTest(type, didcommCredentialExchangeDrizzleRecord)
18
+ })
19
+
20
+ afterAll(async () => {
21
+ await recordTest.teardown()
18
22
  })
19
23
 
20
24
  test('create, retrieve, update, query and delete credential exchange record', async () => {
@@ -58,26 +62,29 @@ describe.each(['postgres', 'sqlite'] as const)('CredentialExchangeRecord with %s
58
62
  },
59
63
  CredentialExchangeRecord
60
64
  )
61
- const credentialExchangeRepository = agent.context.resolve(CredentialRepository)
65
+ const credentialExchangeRepository = recordTest.agent.context.resolve(CredentialRepository)
62
66
 
63
- await credentialExchangeRepository.save(agent.context, credentialExchange)
67
+ await credentialExchangeRepository.save(recordTest.agent.context, credentialExchange)
64
68
 
65
- const credentialExchange2 = await credentialExchangeRepository.findById(agent.context, credentialExchange.id)
69
+ const credentialExchange2 = await credentialExchangeRepository.findById(
70
+ recordTest.agent.context,
71
+ credentialExchange.id
72
+ )
66
73
  expect(credentialExchange).toEqual(credentialExchange2)
67
74
 
68
75
  credentialExchange.setTags({
69
76
  myCustomTag: 'hello',
70
77
  isMorning: false,
71
78
  })
72
- await credentialExchangeRepository.update(agent.context, credentialExchange)
79
+ await credentialExchangeRepository.update(recordTest.agent.context, credentialExchange)
73
80
 
74
- const [credentialExchange3] = await credentialExchangeRepository.findByQuery(agent.context, {
81
+ const [credentialExchange3] = await credentialExchangeRepository.findByQuery(recordTest.agent.context, {
75
82
  isMorning: false,
76
83
  credentialIds: ['8633f56d-abc9-4229-ba09-9ca6611ad8e4'],
77
84
  })
78
85
  expect(credentialExchange3).toEqual(credentialExchange)
79
86
 
80
- const [credentialExchange4] = await credentialExchangeRepository.findByQuery(agent.context, {
87
+ const [credentialExchange4] = await credentialExchangeRepository.findByQuery(recordTest.agent.context, {
81
88
  isMorning: false,
82
89
  // Id does not exist
83
90
  credentialIds: ['a0b7c554-0beb-4a4c-808a-fd4495241770'],
@@ -85,13 +92,13 @@ describe.each(['postgres', 'sqlite'] as const)('CredentialExchangeRecord with %s
85
92
  expect(credentialExchange4).toBeUndefined()
86
93
 
87
94
  expect(
88
- await credentialExchangeRepository.findByQuery(agent.context, {
95
+ await credentialExchangeRepository.findByQuery(recordTest.agent.context, {
89
96
  myCustomTag: 'not-hello',
90
97
  })
91
98
  ).toHaveLength(0)
92
99
 
93
- await credentialExchangeRepository.deleteById(agent.context, credentialExchange.id)
100
+ await credentialExchangeRepository.deleteById(recordTest.agent.context, credentialExchange.id)
94
101
 
95
- expect(await credentialExchangeRepository.findByQuery(agent.context, {})).toHaveLength(0)
102
+ expect(await credentialExchangeRepository.findByQuery(recordTest.agent.context, {})).toHaveLength(0)
96
103
  })
97
104
  })
@@ -1,14 +1,18 @@
1
- import { Agent, JsonTransformer } from '@credo-ts/core'
1
+ import { JsonTransformer } from '@credo-ts/core'
2
2
 
3
3
  import { OutOfBandRecord, OutOfBandRepository } from '@credo-ts/didcomm'
4
- import { setupDrizzleRecordTest } from '../../../../tests/testDatabase'
4
+ import { DrizzleRecordTest, setupDrizzleRecordTest } from '../../../../tests/testDatabase'
5
5
  import { didcommOutOfBandDrizzleRecord } from '../index'
6
6
 
7
7
  describe.each(['postgres', 'sqlite'] as const)('OutOfBandRecord with %s', (type) => {
8
- let agent: Agent
8
+ let recordTest: DrizzleRecordTest
9
9
 
10
10
  beforeAll(async () => {
11
- agent = await setupDrizzleRecordTest(type, didcommOutOfBandDrizzleRecord)
11
+ recordTest = await setupDrizzleRecordTest(type, didcommOutOfBandDrizzleRecord)
12
+ })
13
+
14
+ afterAll(async () => {
15
+ await recordTest.teardown()
12
16
  })
13
17
 
14
18
  test('create, retrieve, update, query and delete out of band record', async () => {
@@ -43,20 +47,20 @@ describe.each(['postgres', 'sqlite'] as const)('OutOfBandRecord with %s', (type)
43
47
  },
44
48
  OutOfBandRecord
45
49
  )
46
- const outOfBandRepository = agent.context.resolve(OutOfBandRepository)
50
+ const outOfBandRepository = recordTest.agent.context.resolve(OutOfBandRepository)
47
51
 
48
- await outOfBandRepository.save(agent.context, outOfBand)
52
+ await outOfBandRepository.save(recordTest.agent.context, outOfBand)
49
53
 
50
- const outOfBand2 = await outOfBandRepository.findById(agent.context, outOfBand.id)
54
+ const outOfBand2 = await outOfBandRepository.findById(recordTest.agent.context, outOfBand.id)
51
55
  expect(outOfBand.toJSON()).toEqual(outOfBand2?.toJSON())
52
56
 
53
57
  outOfBand.setTags({
54
58
  myCustomTag: 'hello',
55
59
  isMorning: false,
56
60
  })
57
- await outOfBandRepository.update(agent.context, outOfBand)
61
+ await outOfBandRepository.update(recordTest.agent.context, outOfBand)
58
62
 
59
- const [outOfBand3] = await outOfBandRepository.findByQuery(agent.context, {
63
+ const [outOfBand3] = await outOfBandRepository.findByQuery(recordTest.agent.context, {
60
64
  isMorning: false,
61
65
 
62
66
  // Tests custom tag mapping (invitationId -> outOfBandInvitation[@id])
@@ -64,7 +68,7 @@ describe.each(['postgres', 'sqlite'] as const)('OutOfBandRecord with %s', (type)
64
68
  })
65
69
  expect(outOfBand3.toJSON()).toEqual(outOfBand.toJSON())
66
70
 
67
- const [outOfBand4] = await outOfBandRepository.findByQuery(agent.context, {
71
+ const [outOfBand4] = await outOfBandRepository.findByQuery(recordTest.agent.context, {
68
72
  isMorning: false,
69
73
  // Id does not exist
70
74
  invitationId: 'a0b7c554-0beb-4a4c-808a-fd4495241770',
@@ -72,13 +76,13 @@ describe.each(['postgres', 'sqlite'] as const)('OutOfBandRecord with %s', (type)
72
76
  expect(outOfBand4).toBeUndefined()
73
77
 
74
78
  expect(
75
- await outOfBandRepository.findByQuery(agent.context, {
79
+ await outOfBandRepository.findByQuery(recordTest.agent.context, {
76
80
  myCustomTag: 'not-hello',
77
81
  })
78
82
  ).toHaveLength(0)
79
83
 
80
- await outOfBandRepository.deleteById(agent.context, outOfBand.id)
84
+ await outOfBandRepository.deleteById(recordTest.agent.context, outOfBand.id)
81
85
 
82
- expect(await outOfBandRepository.findByQuery(agent.context, {})).toHaveLength(0)
86
+ expect(await outOfBandRepository.findByQuery(recordTest.agent.context, {})).toHaveLength(0)
83
87
  })
84
88
  })