Skip to content

Commit

Permalink
Add tests for the Prisma schema generator.
Browse files Browse the repository at this point in the history
Test the basic CRUD capability of the exposed Prisma models.
  • Loading branch information
vpetrovykh committed Dec 19, 2024
1 parent be7976b commit 80ad3b5
Show file tree
Hide file tree
Showing 12 changed files with 932 additions and 1 deletion.
1 change: 1 addition & 0 deletions integration-tests/prisma/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.schema
23 changes: 23 additions & 0 deletions integration-tests/prisma/dbschema/default.esdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module default {
type GameSession {
multi link players: User {
constraint exclusive;
}
required property num: int32;
}

abstract type Named {
required property name: str;
}

type Post {
required link author: User;
required property body: str;
}

type User extending Named;

type UserGroup extending Named {
multi link users: User;
}
}
21 changes: 21 additions & 0 deletions integration-tests/prisma/dbschema/migrations/00001-m1b5kog.edgeql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE MIGRATION m1b5kogggyycxixgy2mcrqu3ntk3hhagdcospowiernk6ddu6op6ia
ONTO initial
{
CREATE ABSTRACT TYPE default::Named {
CREATE REQUIRED PROPERTY name: std::str;
};
CREATE TYPE default::User EXTENDING default::Named;
CREATE TYPE default::GameSession {
CREATE MULTI LINK players: default::User {
CREATE CONSTRAINT std::exclusive;
};
CREATE REQUIRED PROPERTY num: std::int32;
};
CREATE TYPE default::UserGroup EXTENDING default::Named {
CREATE MULTI LINK users: default::User;
};
CREATE TYPE default::Post {
CREATE REQUIRED LINK author: default::User;
CREATE REQUIRED PROPERTY body: std::str;
};
};
2 changes: 2 additions & 0 deletions integration-tests/prisma/gel.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[edgedb]
server-version = "nightly"
9 changes: 9 additions & 0 deletions integration-tests/prisma/globalSetup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import createClient from "edgedb";

export default async () => {
const client = createClient();

process.env._JEST_EDGEDB_VERSION = await client.queryRequiredSingleJSON(
`select sys::get_version()`,
);
};
8 changes: 8 additions & 0 deletions integration-tests/prisma/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testPathIgnorePatterns: ["./dist", "./esm", "./mts", "./cjs", "./deno"],
globalSetup: "./globalSetup.ts",
transform: {},
globals: {},
};
32 changes: 32 additions & 0 deletions integration-tests/prisma/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"private": true,
"name": "@edgedb/integration-prisma",
"version": "0.0.0",
"scripts": {
"typecheck": "echo 'Integration tests - lts, skipping typecheck...'",
"build": "echo 'Integration tests, no build output...'",
"generate": "pwd && npx @edgedb/generate prisma --file prisma.schema && npx prisma generate --schema=prisma.schema",
"test": "yarn test:ts",
"test:ts": "pwd && yarn generate && NODE_OPTIONS=\"--experimental-vm-modules\" jest --testPathIgnorePatterns='(esm/.*|mts/.*|cjs/.*|deno/.*)' --detectOpenHandles --forceExit",
"ci:integration-test": "tsx ./testRunner.ts",
"bench:types": "cd ../.. && tsx integration-tests/lts/bench.ts"
},
"devDependencies": {
"@arktype/attest": "^0.7.8",
"@edgedb/generate": "*",
"@prisma/client": "^6.1.0",
"@tsconfig/node-lts": "^20.1.3",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.13",
"conditional-type-checks": "^1.0.6",
"jest": "^29.7.0",
"prisma": "^6.1.0",
"superjson": "1.13.3",
"ts-jest": "^29.1.4",
"typescript": "^5.5.2"
},
"dependencies": {
"edgedb": "*",
"fast-check": "^3.19.0"
}
}
Loading

0 comments on commit 80ad3b5

Please sign in to comment.