Skip to content

Commit

Permalink
test(client): int overflow #13913 (#15545)
Browse files Browse the repository at this point in the history
* test(client): int overflow

* make tests pass for data proxy

* add comment about the dataproxy issue

* refactor: move to use allProviders

Co-authored-by: Daniel Starns <danielstarns@hotmail.com>
  • Loading branch information
millsp and danstarns committed Sep 27, 2022
1 parent dd9a8d6 commit b0e77cf
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
@@ -0,0 +1,4 @@
import { defineMatrix } from '../../_utils/defineMatrix'
import { allProviders } from '../../_utils/providers'

export default defineMatrix(() => [allProviders])
@@ -0,0 +1,20 @@
import { idForProvider } from '../../../_utils/idForProvider'
import testMatrix from '../_matrix'

export default testMatrix.setupSchema(({ provider }) => {
return /* Prisma */ `
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "${provider}"
url = env("DATABASE_URI_${provider}")
}
model Resource {
id ${idForProvider(provider)}
number Int
}
`
})
@@ -0,0 +1,35 @@
import testMatrix from './_matrix'
// @ts-ignore
import type { PrismaClient } from './node_modules/@prisma/client'

declare let prisma: PrismaClient

testMatrix.setupTestSuite(() => {
test('int overflow', async () => {
const promise = prisma.resource.create({
data: {
number: 2265000000,
},
})

await expect(promise).rejects.toMatchObject({
message: expect.stringContaining('Failed to validate the query'),
code: 'P2009',
})

// TODO: stack trace is not able to locate this error via dataproxy
if (!process.env.DATA_PROXY) {
await expect(promise).rejects.toMatchPrismaErrorInlineSnapshot(`
Invalid \`prisma.resource.create()\` invocation in
/client/tests/functional/issues/13913-integer-overflow/tests.ts:0:0
XX
XX testMatrix.setupTestSuite(() => {
XX test('int overflow', async () => {
→ XX const promise = prisma.resource.create(
Failed to validate the query: \`Unable to match input value to any allowed input type for the field. Parse errors: [Query parsing/validation error at \`Mutation.createOneResource.data.ResourceCreateInput.number\`: Unable to fit integer value '2265000000' into a 32-bit signed integer for field 'number'., Query parsing/validation error at \`Mutation.createOneResource.data.ResourceUncheckedCreateInput.number\`: Unable to fit integer value '2265000000' into a 32-bit signed integer for field 'number'.]\` at \`Mutation.createOneResource.data\`
`)
}
})
})

0 comments on commit b0e77cf

Please sign in to comment.