Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple spaces in PRISMA_DIRECT_URL_REGEXP #8001

Merged
merged 6 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/testing/src/api/__tests__/directUrlHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,19 @@ it("overwrites directUrl if it's set", () => {

delete process.env.RWJS_CWD
})

it("overwrites directUrl if it's set and formatted", () => {
const prismaSchema = `datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}`
process.env.RWJS_CWD = DIRECT_URL_FIXTURE_PATH

const defaultDb = getDefaultDb(DIRECT_URL_FIXTURE_PATH)

const directUrlEnvVar = checkAndReplaceDirectUrl(prismaSchema, defaultDb)

expect(process.env[directUrlEnvVar as string]).toBe(defaultDb)
})
2 changes: 1 addition & 1 deletion packages/testing/src/api/directUrlHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ export function checkAndReplaceDirectUrl(
return directUrlEnv
}

const PRISMA_DIRECT_URL_REGEXP = /directUrl(\s?)=(\s?)env\(('|")(.*)('|")\)/g
const PRISMA_DIRECT_URL_REGEXP = /directUrl(\s*)=(\s*)env\(('|")(.*)('|")\)/g
const BETWEEN_PARENTHESES_REGEXP = /\(('|")([^)]+)('|")\)/