From cf9aba8e8f21fa53ad5592c26025f599c2ac0c8d Mon Sep 17 00:00:00 2001 From: Daniel Starns Date: Tue, 9 Aug 2022 10:02:13 +0100 Subject: [PATCH] test(client): port prisma promise (#14032) * refactor: remove old promise tests * test: add new promise tests * test: add coverage for all methods --- .../happy/prisma-promises/.gitignore | 1 - .../integration/happy/prisma-promises/dev.db | Bin 53248 -> 0 bytes .../happy/prisma-promises/schema.prisma | 29 -- .../integration/happy/prisma-promises/test.ts | 65 ---- .../happy/prismaPromise/.gitignore | 1 - .../integration/happy/prismaPromise/dev.db | Bin 65536 -> 0 bytes .../happy/prismaPromise/schema.prisma | 66 ---- .../integration/happy/prismaPromise/test.ts | 101 ------ .../functional/prisma-promise/_matrix.ts | 24 ++ .../prisma-promise/prisma/_schema.ts | 21 ++ .../tests/functional/prisma-promise/tests.ts | 293 ++++++++++++++++++ 11 files changed, 338 insertions(+), 263 deletions(-) delete mode 100644 packages/client/src/__tests__/integration/happy/prisma-promises/.gitignore delete mode 100644 packages/client/src/__tests__/integration/happy/prisma-promises/dev.db delete mode 100644 packages/client/src/__tests__/integration/happy/prisma-promises/schema.prisma delete mode 100644 packages/client/src/__tests__/integration/happy/prisma-promises/test.ts delete mode 100644 packages/client/src/__tests__/integration/happy/prismaPromise/.gitignore delete mode 100644 packages/client/src/__tests__/integration/happy/prismaPromise/dev.db delete mode 100644 packages/client/src/__tests__/integration/happy/prismaPromise/schema.prisma delete mode 100644 packages/client/src/__tests__/integration/happy/prismaPromise/test.ts create mode 100644 packages/client/tests/functional/prisma-promise/_matrix.ts create mode 100644 packages/client/tests/functional/prisma-promise/prisma/_schema.ts create mode 100644 packages/client/tests/functional/prisma-promise/tests.ts diff --git a/packages/client/src/__tests__/integration/happy/prisma-promises/.gitignore b/packages/client/src/__tests__/integration/happy/prisma-promises/.gitignore deleted file mode 100644 index c8d334f884aa..000000000000 --- a/packages/client/src/__tests__/integration/happy/prisma-promises/.gitignore +++ /dev/null @@ -1 +0,0 @@ -!dev.db diff --git a/packages/client/src/__tests__/integration/happy/prisma-promises/dev.db b/packages/client/src/__tests__/integration/happy/prisma-promises/dev.db deleted file mode 100644 index 4be62b3edd4eaaa2e528aae0b1cb40ec017dc503..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 53248 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 rdq@f-DUhT+EarJ^vm5|9}1;-If0K diff --git a/packages/client/src/__tests__/integration/happy/prisma-promises/schema.prisma b/packages/client/src/__tests__/integration/happy/prisma-promises/schema.prisma deleted file mode 100644 index f82593508957..000000000000 --- a/packages/client/src/__tests__/integration/happy/prisma-promises/schema.prisma +++ /dev/null @@ -1,29 +0,0 @@ -datasource db { - provider = "sqlite" - url = "file:dev.db" -} - -generator client { - provider = "prisma-client-js" -} - -// / User model comment -model User { - id String @default(uuid()) @id - email String @unique - age Int - // / name comment - name String? - posts Post[] -} - -model Post { - id String @default(cuid()) @id - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - published Boolean - title String - content String? - authorId String? - author User? @relation(fields: [authorId], references: [id]) -} diff --git a/packages/client/src/__tests__/integration/happy/prisma-promises/test.ts b/packages/client/src/__tests__/integration/happy/prisma-promises/test.ts deleted file mode 100644 index ca200f8bc4d8..000000000000 --- a/packages/client/src/__tests__/integration/happy/prisma-promises/test.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { getTestClient } from '../../../../utils/getTestClient' - -describe('prisma promises', () => { - /** - * Requests must get sent if we call `.catch` - */ - test('catch', async () => { - const PrismaClient = await getTestClient() - const prisma = new PrismaClient() - const handler = (e) => Promise.reject(e) - - const remove = await prisma.user.deleteMany().catch(handler) - const queryRaw = await prisma.$queryRawUnsafe('SELECT 1').catch(handler) - const executeRaw = await prisma.$executeRawUnsafe('DELETE FROM User').catch(handler) - const findMany = await prisma.user.findMany().catch(handler) - - expect(remove).toMatchInlineSnapshot(` - Object { - count: 0, - } - `) - expect(queryRaw).toMatchInlineSnapshot(` - Array [ - Object { - 1: 1n, - }, - ] - `) - expect(executeRaw).toMatchInlineSnapshot(`0`) - expect(findMany).toMatchInlineSnapshot(`Array []`) - - await prisma.$disconnect() - }) - - /** - * Requests must get sent if we call `.finally` - */ - test('finally', async () => { - const PrismaClient = await getTestClient() - const prisma = new PrismaClient() - const handler = () => {} - - const remove = await prisma.user.deleteMany().finally(handler) - const queryRaw = await prisma.$queryRawUnsafe('SELECT 1').finally(handler) - const executeRaw = await prisma.$executeRawUnsafe('DELETE FROM User').finally(handler) - const findMany = await prisma.user.findMany().finally(handler) - - expect(remove).toMatchInlineSnapshot(` - Object { - count: 0, - } - `) - expect(queryRaw).toMatchInlineSnapshot(` - Array [ - Object { - 1: 1n, - }, - ] - `) - expect(executeRaw).toMatchInlineSnapshot(`0`) - expect(findMany).toMatchInlineSnapshot(`Array []`) - - await prisma.$disconnect() - }) -}) diff --git a/packages/client/src/__tests__/integration/happy/prismaPromise/.gitignore b/packages/client/src/__tests__/integration/happy/prismaPromise/.gitignore deleted file mode 100644 index 97952752a72b..000000000000 --- a/packages/client/src/__tests__/integration/happy/prismaPromise/.gitignore +++ /dev/null @@ -1 +0,0 @@ -!dev.db \ No newline at end of file diff --git a/packages/client/src/__tests__/integration/happy/prismaPromise/dev.db b/packages/client/src/__tests__/integration/happy/prismaPromise/dev.db deleted file mode 100644 index 09b6082e5a8182a125547e2864e74a609f1e6801..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 65536 zcmeI&O;6)S7{GCRfrJD?*aPx`BDucoM%txBXe+fAJRJnwq9fi+xt?-WCxj5n60(Qm^)PyQC(4*emr*$_Yg0R;Xx0!}<^B%4x@G zXZ9*b&V`#Yn=aU?l5LiAnXR&IW^!xxwrTydxMk*ZH|f@Mt9KzQaWWG&KAO`n-&fUS zYe$Y($8oFE?NudHddsMhMTQ}We} zZ%u>cdNs&2QG zWajc>FK4snW+AhYD!es6x8J_#l{r=PcgneWwVi6yKWC@5>zk3z=Zd95Dw8YSw8n$q z7Z8@Yo-f#$H#yk=^EO;&!Ctoub}nrfO-uD(WQx`&WO&!?tSyE@!4_A}q)RfXytyVv zM>@knzdfut2HaC*^VK z`e|5&=!XdvB3YH(CkI31w&4DweYfpYyUt!pv|Em#Qf9-xog8cSda9f)ndx#tjKxw# z<`zq-jZJT=9PbT%vs>i&bf;eH96Dm+t>*JtJC(b+yj!AM>((9Lxnu3Nnq8+UnkMJ0 zTU?Cd! zU%ynr`>Z8yGU^Z-44+C9Bk2C|tBbMWVce1JS5X(P^a}f;xYrpZkpu66<2exu8J`-% z#&fS3N%a)IJR1ue3k&*nsyCwBtz)O%z1Vc0#|LS=sSCjwUD@7$g5aj-3kVqyyh^P07>URsan$?CoDZP1j zAYO})G5d{O@aDD~DG#`p+&}DOiz>%A#e7+Bv+qnuulGK?R6-D*<@0xh9A%Fk^2q1s}0tg_000IagfWYGwcyH`= zWawW5fB8S&e$sLT5I_I{1Q0*~0R#|0009IL7$P9o|M~qt1czh<5I_I{1Q0*~ z0R#|0009I>M1b}G5eX#SKmY**5I_I{1Q0*~0R#|0AV7fi{{S4a5I_I{1Q0*~0R#|0 z009IL7!d*1|3@T{bOQkd5I_I{1Q0*~0R#|00D%Aj*8c-=$U*=C1Q0*~0R#|0009IL zKwv}!SpOf9K++8a5I_I{1Q0*~0R#|0009I71X%wMz#$6(1Q0*~0R#|0009ILKmdUe z5n%m)L;^`S5I_I{1Q0*~0R#|0009IL2oPZXKLCd;1Q0*~0R#|0009ILKmY**MnpjV z{@3GwYU06$00IagfB*srAbtbSx2Z8r52TMI9HN2J8PL5m-8b00Iag rfB*srAb { - test('repeated calls to .then', async () => { - const createPromise = prisma.user.create({ - data: { - email: 'email@email.em', - }, - }) - - // repeated calls to then should not change the result - const createResult1 = await createPromise.then() - const createResult2 = await createPromise.then() - - expect(createResult1).toStrictEqual(createResult2) - }) - - test('repeated calls to .catch', async () => { - const createPromise = prisma.user.create({ - data: { - email: 'email@email.em', - }, - }) - - // repeated calls to catch should not change the result - const createResult1 = await createPromise.catch() - const createResult2 = await createPromise.catch() - - expect(createResult1).toStrictEqual(createResult2) - }) - - test('repeated calls to .finally', async () => { - const createPromise = prisma.user.create({ - data: { - email: 'email@email.em', - }, - }) - - // repeated calls to finally should not change the result - const createResult1 = await createPromise.finally() - const createResult2 = await createPromise.finally() - - expect(createResult1).toStrictEqual(createResult2) - }) - - test('repeated mixed calls to .then, .catch, .finally', async () => { - const createPromise = prisma.user.create({ - data: { - email: 'email@email.em', - }, - }) - - // repeated calls to then & co should not change the result - const createResult1 = await createPromise.finally().then().catch() - const createResult2 = await createPromise.catch().finally().then() - - expect(createResult1).toStrictEqual(createResult2) - }) - - test('repeated calls to .requestTransaction', async () => { - const createPromise = prisma.user.create({ - data: { - email: 'email@email.em', - }, - }) - - // repeated calls to then & co should not change the result - const createResult1 = await createPromise.requestTransaction(1) - const createResult2 = await createPromise.requestTransaction(1) - - expect(createResult1).toStrictEqual(createResult2) - }) - - test('fluent promises should have promise properties', async () => { - const findUniquePromise = prisma.user.findUnique({ - where: { - email: 'email@email.em', - }, - }) - - expect('then' in findUniquePromise).toBe(true) - expect('finally' in findUniquePromise).toBe(true) - expect('catch' in findUniquePromise).toBe(true) - - await findUniquePromise.finally() - }) - - beforeAll(async () => { - const PrismaClient = await getTestClient() - prisma = new PrismaClient() - }) - - beforeEach(async () => { - await prisma.user.deleteMany() - }) - - afterAll(async () => { - await prisma.$disconnect() - }) -}) diff --git a/packages/client/tests/functional/prisma-promise/_matrix.ts b/packages/client/tests/functional/prisma-promise/_matrix.ts new file mode 100644 index 000000000000..655d4c217edc --- /dev/null +++ b/packages/client/tests/functional/prisma-promise/_matrix.ts @@ -0,0 +1,24 @@ +import { defineMatrix } from '../_utils/defineMatrix' + +export default defineMatrix(() => [ + [ + { + provider: 'sqlite', + }, + { + provider: 'postgresql', + }, + { + provider: 'mysql', + }, + { + provider: 'sqlserver', + }, + { + provider: 'cockroachdb', + }, + { + provider: 'mongodb', + }, + ], +]) diff --git a/packages/client/tests/functional/prisma-promise/prisma/_schema.ts b/packages/client/tests/functional/prisma-promise/prisma/_schema.ts new file mode 100644 index 000000000000..53038f9ab0d3 --- /dev/null +++ b/packages/client/tests/functional/prisma-promise/prisma/_schema.ts @@ -0,0 +1,21 @@ +import { idForProvider } from '../../_utils/idForProvider' +import testMatrix from '../_matrix' + +export default testMatrix.setupSchema(({ provider }) => { + return /* Prisma */ ` + datasource db { + provider = "${provider}" + url = env("DATABASE_URI_${provider}") + } + + generator client { + provider = "prisma-client-js" + binaryTargets = ["native"] + } + + model User { + id ${idForProvider(provider)} + email String @unique + } + ` +}) diff --git a/packages/client/tests/functional/prisma-promise/tests.ts b/packages/client/tests/functional/prisma-promise/tests.ts new file mode 100644 index 000000000000..d85f31629c33 --- /dev/null +++ b/packages/client/tests/functional/prisma-promise/tests.ts @@ -0,0 +1,293 @@ +import { faker } from '@faker-js/faker' + +import testMatrix from './_matrix' + +// @ts-ignore this is just for type checks +declare let prisma: import('@prisma/client').PrismaClient + +testMatrix.setupTestSuite(({ provider }) => { + const tests = [ + [ + 'create', + (email: string) => { + return prisma.user.create({ + data: { + email, + }, + }) + }, + ], + ...(provider !== 'sqlite' + ? [ + [ + 'createMany', + (email: string) => { + // @ts-test-if: provider !== 'sqlite' + return prisma.user.createMany({ + data: [ + { + email, + }, + ], + }) + }, + ], + ] + : []), + [ + 'findMany', + (email: string) => { + return prisma.user.findMany({ + where: { + email, + }, + }) + }, + ], + [ + 'findFirst', + (email: string) => { + return prisma.user.findFirst({ + where: { + email, + }, + }) + }, + ], + [ + 'findUnique', + (email: string) => { + return prisma.user.findUnique({ + where: { + email, + }, + }) + }, + ], + [ + 'findUniqueOrThrow', + (email: string) => { + return prisma.user.findUniqueOrThrow({ + where: { + email, + }, + }) + }, + ], + [ + 'findFirstOrThrow', + (email: string) => { + return prisma.user.findFirstOrThrow({ + where: { + email, + }, + }) + }, + ], + [ + 'update', + (email: string) => { + return prisma.user.update({ + where: { + email, + }, + data: { + email, + }, + }) + }, + ], + [ + 'updateMany', + (email: string) => { + return prisma.user.updateMany({ + where: { + email, + }, + data: { + email, + }, + }) + }, + ], + [ + 'delete', + (email: string) => { + return prisma.user.delete({ + where: { + email, + }, + }) + }, + ], + [ + 'deleteMany', + (email: string) => { + return prisma.user.deleteMany({ + where: { + email, + }, + }) + }, + ], + [ + 'aggregate', + (email: string) => { + return prisma.user.aggregate({ + where: { + email, + }, + _count: true, + }) + }, + ], + [ + 'count', + (email: string) => { + return prisma.user.count({ + where: { + email, + }, + }) + }, + ], + ...(provider !== 'mongodb' + ? [ + [ + '$queryRaw', + () => { + // @ts-test-if: provider !== 'mongodb' + return prisma.$queryRaw`SELECT 1 + 1;` + }, + ], + [ + '$queryRawUnsafe', + () => { + // @ts-test-if: provider !== 'mongodb' + return prisma.$queryRawUnsafe(`SELECT 1 + 1;`) + }, + ], + ...(provider !== 'sqlite' + ? [ + [ + '$executeRaw', + () => { + // @ts-test-if: provider !== 'mongodb' + return prisma.$executeRaw`SELECT 1 + 1;` + }, + ], + [ + '$executeRawUnsafe', + () => { + // @ts-test-if: provider !== 'mongodb' + return prisma.$executeRawUnsafe(`SELECT 1 + 1;`) + }, + ], + ] + : []), + ] + : []), + ...(provider === 'mongodb' + ? [ + [ + '$runCommandRaw', + () => { + // @ts-test-if: provider === 'mongodb' + return prisma.$runCommandRaw({ + aggregate: 'User', + pipeline: [{ $match: { name: 'A' } }, { $project: { email: true, _id: false } }], + explain: false, + }) + }, + ], + ] + : []), + ] + + // @ts-ignore function defined in matrix + describe.each(tests)('%s', (name, fn) => { + const email = faker.internet.email() + const createPromise = () => { + // @ts-ignore function defined in matrix + return (fn as (email: string) => any)(email) + } + + beforeEach(async () => { + if ( + ['delete', 'deleteMany', 'update', 'updateMany', 'findFirstOrThrow', 'findUniqueOrThrow'].includes( + name as string, + ) + ) { + await prisma.user.create({ data: { email } }) + } + }) + + afterEach(async () => { + try { + await prisma.user.delete({ where: { email } }) + } catch (error) { + // ignore + } + }) + + test('repeated calls to .then', async () => { + const promise = createPromise() + + // repeated calls to then should not change the result + const res1 = await promise.then() + const res2 = await promise.then() + + expect(res1).toStrictEqual(res2) + }) + + test('repeated calls to .catch', async () => { + const promise = createPromise() + + // repeated calls to catch should not change the result + const res1 = await promise.catch() + const res2 = await promise.catch() + + expect(res1).toStrictEqual(res2) + }) + + test('repeated calls to .finally', async () => { + const promise = createPromise() + + // repeated calls to finally should not change the result + const res1 = await promise.finally() + const res2 = await promise.finally() + + expect(res1).toStrictEqual(res2) + }) + + test('repeated mixed calls to .then, .catch, .finally', async () => { + const promise = createPromise() + + // repeated calls to then & co should not change the result + const res1 = await promise.finally().then().catch() + const res2 = await promise.catch().finally().then() + + expect(res1).toStrictEqual(res2) + }) + + test('repeated calls to .requestTransaction', async () => { + const promise = createPromise() + + // repeated calls to then & co should not change the result + const res1 = await promise.requestTransaction(1) + const res2 = await promise.requestTransaction(1) + + expect(res1).toStrictEqual(res2) + }) + + test('fluent promises should have promise properties', async () => { + const promise = createPromise() + + expect('then' in promise).toBe(true) + expect('finally' in promise).toBe(true) + expect('catch' in promise).toBe(true) + + await promise.finally() + }) + }) +})