@geekmidas/testkit 0.4.0 → 0.6.0

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.
Files changed (209) hide show
  1. package/dist/Factory-BFVnMMCC.mjs.map +1 -1
  2. package/dist/Factory-BhjUOBWN.cjs.map +1 -1
  3. package/dist/{Factory-c16c27Y6.d.cts → Factory-Bx0AJXZB.d.cts} +3 -2
  4. package/dist/Factory-Bx0AJXZB.d.cts.map +1 -0
  5. package/dist/{Factory-BcGJjLc8.d.mts → Factory-SFupxRC2.d.mts} +2 -1
  6. package/dist/Factory-SFupxRC2.d.mts.map +1 -0
  7. package/dist/Factory.d.cts +2 -2
  8. package/dist/Factory.d.mts +1 -1
  9. package/dist/KyselyFactory-BFqVIn_0.cjs.map +1 -1
  10. package/dist/KyselyFactory-DMswpwji.mjs.map +1 -1
  11. package/dist/{KyselyFactory-uZ45h7YU.d.cts → KyselyFactory-KLeKH43i.d.cts} +4 -3
  12. package/dist/KyselyFactory-KLeKH43i.d.cts.map +1 -0
  13. package/dist/{KyselyFactory-Cj-EultY.d.mts → KyselyFactory-vAxYodck.d.mts} +3 -2
  14. package/dist/KyselyFactory-vAxYodck.d.mts.map +1 -0
  15. package/dist/KyselyFactory.d.cts +3 -3
  16. package/dist/KyselyFactory.d.mts +2 -2
  17. package/dist/{ObjectionFactory-DL4qkuF1.d.mts → ObjectionFactory-BWjB49-i.d.mts} +3 -2
  18. package/dist/ObjectionFactory-BWjB49-i.d.mts.map +1 -0
  19. package/dist/ObjectionFactory-BeFBYcan.cjs.map +1 -1
  20. package/dist/ObjectionFactory-QCJ7u0Ql.mjs.map +1 -1
  21. package/dist/{ObjectionFactory-CdhzKs4f.d.cts → ObjectionFactory-aMGvAKt9.d.cts} +4 -3
  22. package/dist/ObjectionFactory-aMGvAKt9.d.cts.map +1 -0
  23. package/dist/ObjectionFactory.d.cts +3 -3
  24. package/dist/ObjectionFactory.d.mts +2 -2
  25. package/dist/{PostgresKyselyMigrator-upT-hmrz.mjs → PostgresKyselyMigrator-6sE1KOni.mjs} +2 -2
  26. package/dist/PostgresKyselyMigrator-6sE1KOni.mjs.map +1 -0
  27. package/dist/{PostgresKyselyMigrator-CIx3AFSR.d.mts → PostgresKyselyMigrator-CBltSOq5.d.cts} +3 -2
  28. package/dist/PostgresKyselyMigrator-CBltSOq5.d.cts.map +1 -0
  29. package/dist/{PostgresKyselyMigrator-CfytARcA.cjs → PostgresKyselyMigrator-D6IbPq8t.cjs} +2 -2
  30. package/dist/PostgresKyselyMigrator-D6IbPq8t.cjs.map +1 -0
  31. package/dist/{PostgresKyselyMigrator-CQ3aUoy_.d.cts → PostgresKyselyMigrator-DrVWncqd.d.mts} +3 -2
  32. package/dist/PostgresKyselyMigrator-DrVWncqd.d.mts.map +1 -0
  33. package/dist/PostgresKyselyMigrator.cjs +2 -2
  34. package/dist/PostgresKyselyMigrator.d.cts +2 -2
  35. package/dist/PostgresKyselyMigrator.d.mts +2 -2
  36. package/dist/PostgresKyselyMigrator.mjs +2 -2
  37. package/dist/{PostgresMigrator-DbuJGAVy.mjs → PostgresMigrator-BjjenqSd.mjs} +2 -2
  38. package/dist/PostgresMigrator-BjjenqSd.mjs.map +1 -0
  39. package/dist/{PostgresMigrator-D5UkK1_K.d.cts → PostgresMigrator-Bres0U6E.d.cts} +2 -1
  40. package/dist/PostgresMigrator-Bres0U6E.d.cts.map +1 -0
  41. package/dist/{PostgresMigrator-DFcNdCvD.cjs → PostgresMigrator-D6dQn0x2.cjs} +2 -2
  42. package/dist/PostgresMigrator-D6dQn0x2.cjs.map +1 -0
  43. package/dist/{PostgresMigrator-DQaRxoaY.d.mts → PostgresMigrator-S-YYosAC.d.mts} +2 -1
  44. package/dist/PostgresMigrator-S-YYosAC.d.mts.map +1 -0
  45. package/dist/PostgresMigrator.cjs +1 -1
  46. package/dist/PostgresMigrator.d.cts +1 -1
  47. package/dist/PostgresMigrator.d.mts +1 -1
  48. package/dist/PostgresMigrator.mjs +1 -1
  49. package/dist/{PostgresObjectionMigrator-CZHHcCOv.d.cts → PostgresObjectionMigrator-CPfBAP7r.d.cts} +3 -2
  50. package/dist/PostgresObjectionMigrator-CPfBAP7r.d.cts.map +1 -0
  51. package/dist/{PostgresObjectionMigrator-BG6ymgnt.cjs → PostgresObjectionMigrator-DK8ODIHQ.cjs} +2 -2
  52. package/dist/PostgresObjectionMigrator-DK8ODIHQ.cjs.map +1 -0
  53. package/dist/{PostgresObjectionMigrator-D_hCcrQu.d.mts → PostgresObjectionMigrator-DVEqB5tp.d.mts} +3 -2
  54. package/dist/PostgresObjectionMigrator-DVEqB5tp.d.mts.map +1 -0
  55. package/dist/{PostgresObjectionMigrator-DPj2pOpX.mjs → PostgresObjectionMigrator-D_QxXbIN.mjs} +2 -2
  56. package/dist/PostgresObjectionMigrator-D_QxXbIN.mjs.map +1 -0
  57. package/dist/PostgresObjectionMigrator.cjs +2 -2
  58. package/dist/PostgresObjectionMigrator.d.cts +2 -2
  59. package/dist/PostgresObjectionMigrator.d.mts +2 -2
  60. package/dist/PostgresObjectionMigrator.mjs +2 -2
  61. package/dist/{VitestKyselyTransactionIsolator-D3EZZhjZ.d.cts → VitestKyselyTransactionIsolator-CduJlHoT.d.cts} +4 -3
  62. package/dist/VitestKyselyTransactionIsolator-CduJlHoT.d.cts.map +1 -0
  63. package/dist/{VitestKyselyTransactionIsolator-Dxlp1u0f.d.mts → VitestKyselyTransactionIsolator-Cswnnj0k.d.mts} +4 -3
  64. package/dist/VitestKyselyTransactionIsolator-Cswnnj0k.d.mts.map +1 -0
  65. package/dist/{VitestKyselyTransactionIsolator-EvDLk5zg.cjs → VitestKyselyTransactionIsolator-D7RRXOBa.cjs} +2 -2
  66. package/dist/VitestKyselyTransactionIsolator-D7RRXOBa.cjs.map +1 -0
  67. package/dist/{VitestKyselyTransactionIsolator-CNURW8y6.mjs → VitestKyselyTransactionIsolator-DceyIqr4.mjs} +2 -2
  68. package/dist/VitestKyselyTransactionIsolator-DceyIqr4.mjs.map +1 -0
  69. package/dist/VitestKyselyTransactionIsolator.cjs +1 -1
  70. package/dist/VitestKyselyTransactionIsolator.d.cts +2 -2
  71. package/dist/VitestKyselyTransactionIsolator.d.mts +2 -2
  72. package/dist/VitestKyselyTransactionIsolator.mjs +1 -1
  73. package/dist/{VitestObjectionTransactionIsolator-1TpsPqfG.d.cts → VitestObjectionTransactionIsolator-BXoR6xdG.d.cts} +4 -3
  74. package/dist/VitestObjectionTransactionIsolator-BXoR6xdG.d.cts.map +1 -0
  75. package/dist/{VitestObjectionTransactionIsolator-CM5KTAFA.cjs → VitestObjectionTransactionIsolator-CdLRrzNf.cjs} +2 -2
  76. package/dist/VitestObjectionTransactionIsolator-CdLRrzNf.cjs.map +1 -0
  77. package/dist/{VitestObjectionTransactionIsolator-jQFaCz0u.mjs → VitestObjectionTransactionIsolator-OF2osYY5.mjs} +2 -2
  78. package/dist/VitestObjectionTransactionIsolator-OF2osYY5.mjs.map +1 -0
  79. package/dist/{VitestObjectionTransactionIsolator-i9jIgU8Q.d.mts → VitestObjectionTransactionIsolator-x6hY5j4u.d.mts} +4 -3
  80. package/dist/VitestObjectionTransactionIsolator-x6hY5j4u.d.mts.map +1 -0
  81. package/dist/VitestObjectionTransactionIsolator.cjs +1 -1
  82. package/dist/VitestObjectionTransactionIsolator.d.cts +2 -2
  83. package/dist/VitestObjectionTransactionIsolator.d.mts +2 -2
  84. package/dist/VitestObjectionTransactionIsolator.mjs +1 -1
  85. package/dist/{VitestTransactionIsolator-BvR19bYn.d.mts → VitestTransactionIsolator-BNWJqh9f.d.mts} +3 -2
  86. package/dist/VitestTransactionIsolator-BNWJqh9f.d.mts.map +1 -0
  87. package/dist/VitestTransactionIsolator-CMfJXZP8.cjs.map +1 -1
  88. package/dist/{VitestTransactionIsolator-CwQaxZLP.d.cts → VitestTransactionIsolator-CSroc7Df.d.cts} +3 -2
  89. package/dist/VitestTransactionIsolator-CSroc7Df.d.cts.map +1 -0
  90. package/dist/VitestTransactionIsolator-DQ7tLqgV.mjs.map +1 -1
  91. package/dist/VitestTransactionIsolator.d.cts +1 -1
  92. package/dist/VitestTransactionIsolator.d.mts +1 -1
  93. package/dist/aws.cjs.map +1 -1
  94. package/dist/aws.d.cts +2 -0
  95. package/dist/aws.d.cts.map +1 -0
  96. package/dist/aws.d.mts +2 -0
  97. package/dist/aws.d.mts.map +1 -0
  98. package/dist/aws.mjs.map +1 -1
  99. package/dist/benchmark.cjs.map +1 -1
  100. package/dist/benchmark.d.cts +1 -0
  101. package/dist/benchmark.d.cts.map +1 -0
  102. package/dist/benchmark.d.mts +1 -0
  103. package/dist/benchmark.d.mts.map +1 -0
  104. package/dist/benchmark.mjs.map +1 -1
  105. package/dist/better-auth.cjs +29 -30
  106. package/dist/better-auth.cjs.map +1 -1
  107. package/dist/better-auth.d.cts +2 -2
  108. package/dist/better-auth.d.cts.map +1 -0
  109. package/dist/better-auth.d.mts.map +1 -0
  110. package/dist/better-auth.mjs +29 -30
  111. package/dist/better-auth.mjs.map +1 -1
  112. package/dist/directory-B-Ozljzk.mjs.map +1 -1
  113. package/dist/directory-BVC8g7cX.cjs.map +1 -1
  114. package/dist/{directory-BXavAeJZ.d.mts → directory-CVrfTq1I.d.mts} +2 -1
  115. package/dist/directory-CVrfTq1I.d.mts.map +1 -0
  116. package/dist/directory-Cys9g76X.d.cts +13 -0
  117. package/dist/directory-Cys9g76X.d.cts.map +1 -0
  118. package/dist/faker-B14IEMIN.cjs.map +1 -1
  119. package/dist/faker-BGKYFoCT.mjs.map +1 -1
  120. package/dist/{faker-DvxiCtxc.d.cts → faker-BSH1EMtg.d.cts} +3 -3
  121. package/dist/faker-BSH1EMtg.d.cts.map +1 -0
  122. package/dist/faker-DHh7xs4u.d.mts.map +1 -0
  123. package/dist/faker.d.cts +1 -1
  124. package/dist/helpers.cjs.map +1 -1
  125. package/dist/helpers.d.cts +1 -0
  126. package/dist/helpers.d.cts.map +1 -0
  127. package/dist/helpers.d.mts +1 -0
  128. package/dist/helpers.d.mts.map +1 -0
  129. package/dist/helpers.mjs.map +1 -1
  130. package/dist/kysely.cjs +3 -3
  131. package/dist/kysely.cjs.map +1 -1
  132. package/dist/kysely.d.cts +8 -7
  133. package/dist/kysely.d.cts.map +1 -0
  134. package/dist/kysely.d.mts +7 -6
  135. package/dist/kysely.d.mts.map +1 -0
  136. package/dist/kysely.mjs +3 -3
  137. package/dist/kysely.mjs.map +1 -1
  138. package/dist/logger.cjs.map +1 -1
  139. package/dist/logger.d.cts +1 -0
  140. package/dist/logger.d.cts.map +1 -0
  141. package/dist/logger.d.mts +1 -0
  142. package/dist/logger.d.mts.map +1 -0
  143. package/dist/logger.mjs.map +1 -1
  144. package/dist/objection.cjs +3 -3
  145. package/dist/objection.cjs.map +1 -1
  146. package/dist/objection.d.cts +8 -7
  147. package/dist/objection.d.cts.map +1 -0
  148. package/dist/objection.d.mts +7 -6
  149. package/dist/objection.d.mts.map +1 -0
  150. package/dist/objection.mjs +3 -3
  151. package/dist/objection.mjs.map +1 -1
  152. package/dist/os/directory.d.cts +1 -1
  153. package/dist/os/directory.d.mts +1 -1
  154. package/dist/os/index.d.cts +1 -1
  155. package/dist/os/index.d.mts +1 -1
  156. package/dist/timer.cjs.map +1 -1
  157. package/dist/timer.d.cts +2 -0
  158. package/dist/timer.d.cts.map +1 -0
  159. package/dist/timer.d.mts +2 -0
  160. package/dist/timer.d.mts.map +1 -0
  161. package/dist/timer.mjs.map +1 -1
  162. package/package.json +5 -5
  163. package/src/Factory.ts +72 -72
  164. package/src/KyselyFactory.ts +330 -330
  165. package/src/ObjectionFactory.ts +354 -355
  166. package/src/PostgresKyselyMigrator.ts +37 -37
  167. package/src/PostgresMigrator.ts +107 -107
  168. package/src/PostgresObjectionMigrator.ts +91 -91
  169. package/src/VitestKyselyTransactionIsolator.ts +27 -27
  170. package/src/VitestObjectionTransactionIsolator.ts +39 -39
  171. package/src/VitestTransactionIsolator.ts +196 -195
  172. package/src/__tests__/Factory.spec.ts +163 -155
  173. package/src/__tests__/KyselyFactory.spec.ts +443 -439
  174. package/src/__tests__/ObjectionFactory.spec.ts +563 -557
  175. package/src/__tests__/PostgresKyselyMigrator.spec.ts +641 -641
  176. package/src/__tests__/PostgresMigrator.spec.ts +341 -341
  177. package/src/__tests__/PostgresObjectionMigrator.spec.ts +578 -578
  178. package/src/__tests__/VitestObjectionTransactionIsolator.spec.ts +114 -114
  179. package/src/__tests__/benchmark.spec.ts +140 -0
  180. package/src/__tests__/better-auth.spec.ts +15 -15
  181. package/src/__tests__/faker.spec.ts +226 -137
  182. package/src/__tests__/integration.spec.ts +597 -597
  183. package/src/__tests__/utilities.spec.ts +211 -0
  184. package/src/aws.ts +104 -104
  185. package/src/benchmark.ts +12 -12
  186. package/src/better-auth.ts +286 -301
  187. package/src/faker.ts +153 -153
  188. package/src/helpers.ts +6 -6
  189. package/src/kysely.ts +33 -33
  190. package/src/logger.ts +10 -10
  191. package/src/objection.ts +31 -31
  192. package/src/os/directory.ts +11 -10
  193. package/src/timer.ts +1 -1
  194. package/test/globalSetup.ts +45 -45
  195. package/test/helpers.ts +189 -189
  196. package/test/migrations/1749664623372_user.ts +13 -13
  197. package/tsconfig.json +9 -0
  198. package/vitest.config.ts +4 -4
  199. package/dist/PostgresKyselyMigrator-CfytARcA.cjs.map +0 -1
  200. package/dist/PostgresKyselyMigrator-upT-hmrz.mjs.map +0 -1
  201. package/dist/PostgresMigrator-DFcNdCvD.cjs.map +0 -1
  202. package/dist/PostgresMigrator-DbuJGAVy.mjs.map +0 -1
  203. package/dist/PostgresObjectionMigrator-BG6ymgnt.cjs.map +0 -1
  204. package/dist/PostgresObjectionMigrator-DPj2pOpX.mjs.map +0 -1
  205. package/dist/VitestKyselyTransactionIsolator-CNURW8y6.mjs.map +0 -1
  206. package/dist/VitestKyselyTransactionIsolator-EvDLk5zg.cjs.map +0 -1
  207. package/dist/VitestObjectionTransactionIsolator-CM5KTAFA.cjs.map +0 -1
  208. package/dist/VitestObjectionTransactionIsolator-jQFaCz0u.mjs.map +0 -1
  209. package/dist/directory-Mi7tdOuD.d.cts +0 -12
@@ -6,133 +6,133 @@ import { wrapVitestObjectionTransaction } from '../objection';
6
6
 
7
7
  // Define Objection models for testing
8
8
  class User extends Model {
9
- static get tableName() {
10
- return 'users';
11
- }
12
-
13
- id!: number;
14
- name!: string;
15
- createdAt!: Date;
16
- updatedAt?: Date;
17
-
18
- static get relationMappings() {
19
- return {
20
- posts: {
21
- relation: Model.HasManyRelation,
22
- modelClass: Post,
23
- join: {
24
- from: 'users.id',
25
- to: 'posts.user_id',
26
- },
27
- },
28
- comments: {
29
- relation: Model.HasManyRelation,
30
- modelClass: Comment,
31
- join: {
32
- from: 'users.id',
33
- to: 'comments.user_id',
34
- },
35
- },
36
- };
37
- }
9
+ static get tableName() {
10
+ return 'users';
11
+ }
12
+
13
+ id!: number;
14
+ name!: string;
15
+ createdAt!: Date;
16
+ updatedAt?: Date;
17
+
18
+ static get relationMappings() {
19
+ return {
20
+ posts: {
21
+ relation: Model.HasManyRelation,
22
+ modelClass: Post,
23
+ join: {
24
+ from: 'users.id',
25
+ to: 'posts.user_id',
26
+ },
27
+ },
28
+ comments: {
29
+ relation: Model.HasManyRelation,
30
+ modelClass: Comment,
31
+ join: {
32
+ from: 'users.id',
33
+ to: 'comments.user_id',
34
+ },
35
+ },
36
+ };
37
+ }
38
38
  }
39
39
 
40
40
  class Post extends Model {
41
- static get tableName() {
42
- return 'posts';
43
- }
44
-
45
- id!: number;
46
- title!: string;
47
- content!: string;
48
- userId!: number;
49
- published?: boolean;
50
- createdAt!: Date;
51
- updatedAt?: Date;
52
-
53
- static get relationMappings() {
54
- return {
55
- user: {
56
- relation: Model.BelongsToOneRelation,
57
- modelClass: User,
58
- join: {
59
- from: 'posts.user_id',
60
- to: 'users.id',
61
- },
62
- },
63
- comments: {
64
- relation: Model.HasManyRelation,
65
- modelClass: Comment,
66
- join: {
67
- from: 'posts.id',
68
- to: 'comments.post_id',
69
- },
70
- },
71
- };
72
- }
41
+ static get tableName() {
42
+ return 'posts';
43
+ }
44
+
45
+ id!: number;
46
+ title!: string;
47
+ content!: string;
48
+ userId!: number;
49
+ published?: boolean;
50
+ createdAt!: Date;
51
+ updatedAt?: Date;
52
+
53
+ static get relationMappings() {
54
+ return {
55
+ user: {
56
+ relation: Model.BelongsToOneRelation,
57
+ modelClass: User,
58
+ join: {
59
+ from: 'posts.user_id',
60
+ to: 'users.id',
61
+ },
62
+ },
63
+ comments: {
64
+ relation: Model.HasManyRelation,
65
+ modelClass: Comment,
66
+ join: {
67
+ from: 'posts.id',
68
+ to: 'comments.post_id',
69
+ },
70
+ },
71
+ };
72
+ }
73
73
  }
74
74
 
75
75
  class Comment extends Model {
76
- static get tableName() {
77
- return 'comments';
78
- }
79
-
80
- id!: number;
81
- content!: string;
82
- postId!: number;
83
- userId!: number;
84
- createdAt!: Date;
85
-
86
- static get relationMappings() {
87
- return {
88
- post: {
89
- relation: Model.BelongsToOneRelation,
90
- modelClass: Post,
91
- join: {
92
- from: 'comments.post_id',
93
- to: 'posts.id',
94
- },
95
- },
96
- user: {
97
- relation: Model.BelongsToOneRelation,
98
- modelClass: User,
99
- join: {
100
- from: 'comments.user_id',
101
- to: 'users.id',
102
- },
103
- },
104
- };
105
- }
76
+ static get tableName() {
77
+ return 'comments';
78
+ }
79
+
80
+ id!: number;
81
+ content!: string;
82
+ postId!: number;
83
+ userId!: number;
84
+ createdAt!: Date;
85
+
86
+ static get relationMappings() {
87
+ return {
88
+ post: {
89
+ relation: Model.BelongsToOneRelation,
90
+ modelClass: Post,
91
+ join: {
92
+ from: 'comments.post_id',
93
+ to: 'posts.id',
94
+ },
95
+ },
96
+ user: {
97
+ relation: Model.BelongsToOneRelation,
98
+ modelClass: User,
99
+ join: {
100
+ from: 'comments.user_id',
101
+ to: 'users.id',
102
+ },
103
+ },
104
+ };
105
+ }
106
106
  }
107
107
 
108
108
  // Create database connection
109
109
 
110
110
  // Create wrapped test with transaction isolation
111
111
  const it = wrapVitestObjectionTransaction(base, {
112
- connection: createKnexDb,
113
- setup: async (trx) => {
114
- // Create tables in the transaction
115
- await createTestTablesKnex(trx);
116
- },
112
+ connection: createKnexDb,
113
+ setup: async (trx) => {
114
+ // Create tables in the transaction
115
+ await createTestTablesKnex(trx);
116
+ },
117
117
  });
118
118
 
119
119
  describe('VitestObjectionTransactionIsolator', () => {
120
- describe('Transaction Isolation', () => {
121
- it('should rollback data after test completes', async ({ trx }) => {
122
- // Create a user within the transaction
123
- const user = await User.query(trx).insert({
124
- name: 'Test User',
125
- });
126
-
127
- expect(user).toBeDefined();
128
- expect(user.id).toBeDefined();
129
- expect(user.name).toBe('Test User');
130
-
131
- // Verify user exists in transaction
132
- const foundUser = await User.query(trx).findById(user.id);
133
- expect(foundUser).toBeDefined();
134
-
135
- // Data will be rolled back after this test
136
- });
137
- });
120
+ describe('Transaction Isolation', () => {
121
+ it('should rollback data after test completes', async ({ trx }) => {
122
+ // Create a user within the transaction
123
+ const user = await User.query(trx).insert({
124
+ name: 'Test User',
125
+ });
126
+
127
+ expect(user).toBeDefined();
128
+ expect(user.id).toBeDefined();
129
+ expect(user.name).toBe('Test User');
130
+
131
+ // Verify user exists in transaction
132
+ const foundUser = await User.query(trx).findById(user.id);
133
+ expect(foundUser).toBeDefined();
134
+
135
+ // Data will be rolled back after this test
136
+ });
137
+ });
138
138
  });
@@ -0,0 +1,140 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import {
3
+ generateCacheKeys,
4
+ generateIpAddresses,
5
+ generateTestData,
6
+ randomIpAddress,
7
+ } from '../benchmark';
8
+
9
+ describe('generateTestData', () => {
10
+ it('should generate the specified number of records', () => {
11
+ const data = generateTestData(5);
12
+ expect(data).toHaveLength(5);
13
+ });
14
+
15
+ it('should generate records with expected structure', () => {
16
+ const data = generateTestData(3);
17
+
18
+ for (const record of data) {
19
+ expect(record).toHaveProperty('id');
20
+ expect(record).toHaveProperty('name');
21
+ expect(record).toHaveProperty('value');
22
+ expect(typeof record.id).toBe('string');
23
+ expect(typeof record.name).toBe('string');
24
+ expect(typeof record.value).toBe('number');
25
+ }
26
+ });
27
+
28
+ it('should generate sequential IDs', () => {
29
+ const data = generateTestData(3);
30
+ expect(data[0].id).toBe('id-0');
31
+ expect(data[1].id).toBe('id-1');
32
+ expect(data[2].id).toBe('id-2');
33
+ });
34
+
35
+ it('should generate sequential names', () => {
36
+ const data = generateTestData(3);
37
+ expect(data[0].name).toBe('Item 0');
38
+ expect(data[1].name).toBe('Item 1');
39
+ expect(data[2].name).toBe('Item 2');
40
+ });
41
+
42
+ it('should generate random values between 0 and 1000', () => {
43
+ const data = generateTestData(100);
44
+
45
+ for (const record of data) {
46
+ expect(record.value).toBeGreaterThanOrEqual(0);
47
+ expect(record.value).toBeLessThan(1000);
48
+ }
49
+ });
50
+
51
+ it('should return empty array for count 0', () => {
52
+ const data = generateTestData(0);
53
+ expect(data).toEqual([]);
54
+ });
55
+ });
56
+
57
+ describe('generateCacheKeys', () => {
58
+ it('should generate the specified number of keys', () => {
59
+ const keys = generateCacheKeys('test', 5);
60
+ expect(keys).toHaveLength(5);
61
+ });
62
+
63
+ it('should use the provided prefix', () => {
64
+ const keys = generateCacheKeys('user', 3);
65
+ expect(keys[0]).toBe('user:0');
66
+ expect(keys[1]).toBe('user:1');
67
+ expect(keys[2]).toBe('user:2');
68
+ });
69
+
70
+ it('should return empty array for count 0', () => {
71
+ const keys = generateCacheKeys('test', 0);
72
+ expect(keys).toEqual([]);
73
+ });
74
+
75
+ it('should handle empty prefix', () => {
76
+ const keys = generateCacheKeys('', 2);
77
+ expect(keys[0]).toBe(':0');
78
+ expect(keys[1]).toBe(':1');
79
+ });
80
+ });
81
+
82
+ describe('generateIpAddresses', () => {
83
+ it('should generate the specified number of IPs', () => {
84
+ const ips = generateIpAddresses(5);
85
+ expect(ips).toHaveLength(5);
86
+ });
87
+
88
+ it('should use default subnet 192.168.1', () => {
89
+ const ips = generateIpAddresses(3);
90
+ expect(ips[0]).toBe('192.168.1.0');
91
+ expect(ips[1]).toBe('192.168.1.1');
92
+ expect(ips[2]).toBe('192.168.1.2');
93
+ });
94
+
95
+ it('should use custom subnet', () => {
96
+ const ips = generateIpAddresses(2, '10.0.0');
97
+ expect(ips[0]).toBe('10.0.0.0');
98
+ expect(ips[1]).toBe('10.0.0.1');
99
+ });
100
+
101
+ it('should wrap last octet at 256', () => {
102
+ const ips = generateIpAddresses(260);
103
+ expect(ips[0]).toBe('192.168.1.0');
104
+ expect(ips[255]).toBe('192.168.1.255');
105
+ expect(ips[256]).toBe('192.168.1.0'); // Wraps around
106
+ expect(ips[257]).toBe('192.168.1.1');
107
+ });
108
+
109
+ it('should return empty array for count 0', () => {
110
+ const ips = generateIpAddresses(0);
111
+ expect(ips).toEqual([]);
112
+ });
113
+ });
114
+
115
+ describe('randomIpAddress', () => {
116
+ it('should generate valid IP address format', () => {
117
+ const ip = randomIpAddress();
118
+ const parts = ip.split('.');
119
+
120
+ expect(parts).toHaveLength(4);
121
+
122
+ for (const part of parts) {
123
+ const num = Number.parseInt(part, 10);
124
+ expect(num).toBeGreaterThanOrEqual(0);
125
+ expect(num).toBeLessThanOrEqual(255);
126
+ }
127
+ });
128
+
129
+ it('should generate different IPs on multiple calls', () => {
130
+ const ips = new Set<string>();
131
+
132
+ // Generate 10 IPs and check we get at least some variation
133
+ for (let i = 0; i < 10; i++) {
134
+ ips.add(randomIpAddress());
135
+ }
136
+
137
+ // With random generation, we should get at least 2 unique IPs
138
+ expect(ips.size).toBeGreaterThan(1);
139
+ });
140
+ });
@@ -2,20 +2,20 @@ import { runAdapterTest } from 'better-auth/adapters/test';
2
2
  import { afterAll, describe } from 'vitest';
3
3
  import { memoryAdapter } from '../better-auth';
4
4
 
5
- describe.skip('Memory Adapter Tests', async () => {
6
- afterAll(async () => {
7
- // Run DB cleanup here...
8
- });
9
- const adapter = memoryAdapter({
10
- debugLogs: {
11
- // If your adapter config allows passing in debug logs, then pass this here.
12
- isRunningAdapterTests: true, // This is our super secret flag to let us know to only log debug logs if a test fails.
13
- },
14
- });
5
+ describe('Memory Adapter Tests', async () => {
6
+ afterAll(async () => {
7
+ // Run DB cleanup here...
8
+ });
9
+ const adapter = memoryAdapter({
10
+ debugLogs: {
11
+ // If your adapter config allows passing in debug logs, then pass this here.
12
+ isRunningAdapterTests: true, // This is our super secret flag to let us know to only log debug logs if a test fails.
13
+ },
14
+ });
15
15
 
16
- await runAdapterTest({
17
- getAdapter: async (betterAuthOptions = {}) => {
18
- return adapter(betterAuthOptions);
19
- },
20
- });
16
+ await runAdapterTest({
17
+ getAdapter: async (betterAuthOptions = {}) => {
18
+ return adapter(betterAuthOptions);
19
+ },
20
+ });
21
21
  });