Skip to content

Commit

Permalink
test: Automatic insertion of relation attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
avocadowastaken committed Mar 3, 2022
1 parent 1135991 commit 74452ff
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 25 deletions.
9 changes: 8 additions & 1 deletion test/__fixtures__/unformatted.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,11 @@ email String @unique
name String?
Post Post[]
Profile Profile?
}
}

model Comment {
id Int @default(autoincrement()) @id
content String
author User
post Post
}
92 changes: 68 additions & 24 deletions test/plugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ test("basic", () => {
}
model Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
title String
content String?
published Boolean @default(false)
User User @relation(fields: [authorId], references: [id])
published Boolean @default(false)
User User @relation(fields: [authorId], references: [id])
authorId Int
Comment Comment[]
}
model Profile {
Expand All @@ -53,11 +54,21 @@ test("basic", () => {
}
model User {
id Int @id @default(autoincrement())
email String @unique
id Int @id @default(autoincrement())
email String @unique
name String?
Post Post[]
Profile Profile?
Comment Comment[]
}
model Comment {
id Int @id @default(autoincrement())
content String
author User @relation(fields: [userId], references: [id])
post Post @relation(fields: [postId], references: [id])
userId Int
postId Int
}
`);
Expand Down Expand Up @@ -96,13 +107,14 @@ test("markdown", () => {
}
model Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
title String
content String?
published Boolean @default(false)
User User @relation(fields: [authorId], references: [id])
published Boolean @default(false)
User User @relation(fields: [authorId], references: [id])
authorId Int
Comment Comment[]
}
model Profile {
Expand All @@ -113,11 +125,21 @@ test("markdown", () => {
}
model User {
id Int @id @default(autoincrement())
email String @unique
id Int @id @default(autoincrement())
email String @unique
name String?
Post Post[]
Profile Profile?
Comment Comment[]
}
model Comment {
id Int @id @default(autoincrement())
content String
author User @relation(fields: [userId], references: [id])
post Post @relation(fields: [postId], references: [id])
userId Int
postId Int
}
\`\`\`
Expand All @@ -142,13 +164,14 @@ test("markdown", () => {
}
model Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
title String
content String?
published Boolean @default(false)
User User @relation(fields: [authorId], references: [id])
published Boolean @default(false)
User User @relation(fields: [authorId], references: [id])
authorId Int
Comment Comment[]
}
model Profile {
Expand All @@ -159,11 +182,21 @@ test("markdown", () => {
}
model User {
id Int @id @default(autoincrement())
email String @unique
id Int @id @default(autoincrement())
email String @unique
name String?
Post Post[]
Profile Profile?
Comment Comment[]
}
model Comment {
id Int @id @default(autoincrement())
content String
author User @relation(fields: [userId], references: [id])
post Post @relation(fields: [postId], references: [id])
userId Int
postId Int
}
\`\`\`
Expand All @@ -183,13 +216,14 @@ test("tabWidth", () => {
}
model Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
title String
content String?
published Boolean @default(false)
User User @relation(fields: [authorId], references: [id])
published Boolean @default(false)
User User @relation(fields: [authorId], references: [id])
authorId Int
Comment Comment[]
}
model Profile {
Expand All @@ -200,11 +234,21 @@ test("tabWidth", () => {
}
model User {
id Int @id @default(autoincrement())
email String @unique
id Int @id @default(autoincrement())
email String @unique
name String?
Post Post[]
Profile Profile?
Comment Comment[]
}
model Comment {
id Int @id @default(autoincrement())
content String
author User @relation(fields: [userId], references: [id])
post Post @relation(fields: [postId], references: [id])
userId Int
postId Int
}
`);
Expand Down

0 comments on commit 74452ff

Please sign in to comment.