mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
improve auto-migration test
This commit is contained in:
parent
f7b1d20ce8
commit
6cfc7b7e91
@ -201,8 +201,8 @@ import.meta.vitest?.test("applies migrations concurrently", runTest(async ({ exp
|
||||
const l1 = result1.newlyAppliedMigrationNames.length;
|
||||
const l2 = result2.newlyAppliedMigrationNames.length;
|
||||
|
||||
// One of the two migrations should be applied, but not both
|
||||
expect((l1 === 2 && l2 === 0) || (l1 === 0 && l2 === 2)).toBe(true);
|
||||
// the sum of the two should be 2
|
||||
expect(l1 + l2).toBe(2);
|
||||
|
||||
await prismaClient.$executeRaw`INSERT INTO test (name) VALUES ('test_value')`;
|
||||
const result = await prismaClient.$queryRaw`SELECT name FROM test` as { name: string }[];
|
||||
@ -222,9 +222,12 @@ import.meta.vitest?.test("applies migrations concurrently with 20 concurrent mig
|
||||
const appliedCounts = results.map(result => result.newlyAppliedMigrationNames.length);
|
||||
|
||||
// Only one of the promises should have applied all migrations, the rest should have applied none
|
||||
const appliedCounts = results.map(result => result.newlyAppliedMigrationNames.length);
|
||||
const appliedSum = appliedCounts.reduce((sum, count) => sum + count, 0);
|
||||
const successfulApplies = appliedCounts.filter(count => count > 0);
|
||||
const emptyApplies = appliedCounts.filter(count => count === 0);
|
||||
|
||||
const appliedSum = successfulApplies.reduce((sum, count) => sum + count, 0);
|
||||
expect(appliedSum).toBe(2);
|
||||
expect(emptyApplies.length).toBe(19);
|
||||
|
||||
await prismaClient.$executeRaw`INSERT INTO test (name) VALUES ('test_value')`;
|
||||
const result = await prismaClient.$queryRaw`SELECT name FROM test` as { name: string }[];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user