-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(client): Add cockroachdb blog tests (#10772)
- Loading branch information
1 parent
1f8e4ef
commit f0631b2
Showing
10 changed files
with
450 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...es/client/src/__tests__/integration/happy/blog-env-cockroachdb/__snapshots__/test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Blog fixture: Cockroachdb $queryRaw $queryRaw(string) error 1`] = ` | ||
\`$queryRaw\` is a tag function, please use it like the following: | ||
\`\`\` | ||
const result = await prisma.$queryRaw\`SELECT * FROM User WHERE id = \${1} OR email = \${'user@email.com'};\` | ||
\`\`\` | ||
Or read our docs at https://www.prisma.io/docs/concepts/components/prisma-client/raw-database-access#queryraw | ||
`; |
36 changes: 36 additions & 0 deletions
36
packages/client/src/__tests__/integration/happy/blog-env-cockroachdb/schema.prisma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
datasource db { | ||
provider = "cockroachdb" | ||
url = env("TEST_COCKROACH_URI") | ||
} | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
previewFeatures = ["cockroachdb"] | ||
} | ||
|
||
// / User model comment | ||
model User { | ||
id String @id @default(uuid()) | ||
email String @unique | ||
// / name comment | ||
name String? | ||
posts Post[] | ||
} | ||
|
||
model Post { | ||
id String @id @default(cuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
published Boolean | ||
title String | ||
content String? | ||
jsonData Json? | ||
coinflips Boolean[] | ||
authorId String? | ||
author User? @relation(fields: [authorId], references: [id]) | ||
} | ||
|
||
enum Role { | ||
USER | ||
ADMIN | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/client/src/__tests__/integration/happy/blog-env-cockroachdb/setup.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
DROP TYPE IF EXISTS "Role"; | ||
CREATE TYPE "Role" AS ENUM ('USER', 'ADMIN'); | ||
DROP TABLE IF EXISTS "public"."Post" CASCADE; | ||
CREATE TABLE "public"."Post" ( | ||
"id" text NOT NULL, | ||
"createdAt" timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" timestamp(3) NOT NULL DEFAULT '1970-01-01 00:00:00'::timestamp without time zone, | ||
"published" boolean NOT NULL DEFAULT false, | ||
"title" text NOT NULL, | ||
"content" text, | ||
"authorId" text, | ||
"jsonData" jsonb, | ||
"coinflips" _bool, | ||
PRIMARY KEY ("id") | ||
); | ||
DROP TABLE IF EXISTS "public"."User" CASCADE; | ||
CREATE TABLE "public"."User" ( | ||
"id" text, | ||
"email" text NOT NULL, | ||
"name" text, | ||
PRIMARY KEY ("id") | ||
); | ||
CREATE UNIQUE INDEX "User.email" ON "public"."User"("email"); | ||
ALTER TABLE "public"."Post" | ||
ADD FOREIGN KEY ("authorId") REFERENCES "public"."User"("id") ON DELETE | ||
SET NULL ON UPDATE CASCADE; | ||
INSERT INTO "public"."User" (email, id, name) | ||
VALUES ( | ||
'a@a.de', | ||
'576eddf9-2434-421f-9a86-58bede16fd95', | ||
'Alice' | ||
); |
Oops, something went wrong.