MCPcopy
hub / github.com/prisma/prisma / testSchemaPath

Function testSchemaPath

packages/internals/src/__tests__/getSchema.test.ts:23–52  ·  view source on GitHub ↗
({
  fixtureName,
  schemaPathFromArgs,
  schemaPathFromConfig,
}: {
  fixtureName: string
  schemaPathFromArgs?: string
  schemaPathFromConfig?: string
})

Source from the content-addressed store, hash-verified

21}
22
23async function testSchemaPath({
24 fixtureName,
25 schemaPathFromArgs,
26 schemaPathFromConfig,
27}: {
28 fixtureName: string
29 schemaPathFromArgs?: string
30 schemaPathFromConfig?: string
31}) {
32 const cwd = path.resolve(FIXTURE_CWD, fixtureName)
33
34 let asyncResult: string | null | Error
35
36 try {
37 const schemaPath = createSchemaPathInput({ schemaPathFromArgs, schemaPathFromConfig, baseDir: cwd })
38 asyncResult = (await getSchemaWithPath({ schemaPath, cwd }))?.schemaPath ?? null
39 } catch (e) {
40 asyncResult = e as Error
41 }
42
43 if (typeof asyncResult === 'string') {
44 asyncResult = stripVTControlCharacters(toUnixPath(path.relative('.', asyncResult)))
45 }
46
47 if (asyncResult instanceof Error) {
48 asyncResult.message = stripVTControlCharacters(toUnixPath(asyncResult.message.replace(__dirname, '.')))
49 }
50
51 return asyncResult
52}
53
54it('throws error if schema is not found', async () => {
55 const res = await testSchemaPath({ fixtureName: 'no-schema' })

Callers 1

getSchema.test.tsFile · 0.85

Calls 3

createSchemaPathInputFunction · 0.90
getSchemaWithPathFunction · 0.90
toUnixPathFunction · 0.85

Tested by

no test coverage detected