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

test(cli): add prismaSchemaFolder-specific tests #24141

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

jkomyno
Copy link
Contributor

@jkomyno jkomyno commented May 9, 2024

WIP

This PR closes https://github.com/prisma/team-orm/issues/1137.
It adds test cases to:

  • packages/cli
    • validate
    • format
    • generate
  • packages/internals
    • getDmmf
    • getConfig
    • getSchema

This PR also adds a new tree() utility to jestContext, which provides a JavaScript-friendly implementation of the tree UNIX command. It returns a string showcasing the file and directory structure starting from the fixture root directory:

import { jestContext } from '@prisma/get-platform'

const ctx = jestContext.new().assemble()

describe('validate', () => {
  it('some test using fixtures with many files and folders', () => {
    ctx.fixture('multi-schema-files/valid')
    expect(ctx.tree()).toMatchInlineSnapshot(`
      "
      └── prisma/
          └── schema/
              └── schema1.prisma
              └── schema2.prisma
          └── custom.prisma
          └── schema.prisma
      └── custom.prisma
      └── schema.prisma
      "
    `)
  })
})

The prismaSchemaFolder preview feature, which allows reading multiple schema files at once and combine them as a single schema, heavily relies on the file disk structure. This ctx.tree() utility allows to snapshot the disk structure in the tests, allowing easy future reference for Prisma developers.

Copy link
Contributor

github-actions bot commented May 9, 2024

size-limit report 📦

Path Size
packages/client/runtime/library.js 179.82 KB (0%)
packages/client/runtime/library.d.ts 81 B (0%)
packages/client/runtime/binary.js 600.89 KB (0%)
packages/client/runtime/binary.d.ts 26 B (0%)
packages/client/runtime/edge.js 159.02 KB (0%)
packages/client/runtime/edge-esm.js 158.91 KB (0%)
packages/client/runtime/wasm.js 114.9 KB (0%)
packages/client/runtime/index-browser.js 33.77 KB (0%)
packages/client/runtime/index-browser.d.ts 89 B (0%)
packages/cli/build/index.js 2.1 MB (+0.01% 🔺)
packages/client/prisma-client-0.0.0.tgz 2.93 MB (0%)
packages/cli/prisma-0.0.0.tgz 3.73 MB (+0.01% 🔺)
packages/bundle-size/da-workers-libsql/output.tgz 858.74 KB (0%)
packages/bundle-size/da-workers-neon/output.tgz 934.97 KB (0%)
packages/bundle-size/da-workers-pg/output.tgz 953.54 KB (0%)
packages/bundle-size/da-workers-pg-worker/output.tgz 909.25 KB (0%)
packages/bundle-size/da-workers-planetscale/output.tgz 870.88 KB (0%)
packages/bundle-size/da-workers-d1/output.tgz 830.95 KB (0%)

@jkomyno jkomyno self-assigned this May 9, 2024
@jkomyno jkomyno added this to the 5.14.0 milestone May 9, 2024
Copy link

codspeed-hq bot commented May 9, 2024

CodSpeed Performance Report

Merging #24141 will degrade performances by 24.15%

Comparing feat/test-prismaSchemaFolder (aaa7463) with main (79de5cf)

Summary

❌ 1 regressions
✅ 2 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main feat/test-prismaSchemaFolder Change
client generation 100 models with relations 5.8 s 7.6 s -24.15%

@jkomyno jkomyno modified the milestones: 5.14.0, 5.15.0 May 13, 2024
@jkomyno jkomyno assigned SevInf and unassigned jkomyno May 28, 2024
@SevInf SevInf force-pushed the feat/test-prismaSchemaFolder branch from 8130b96 to cb2fc86 Compare May 31, 2024 09:52
@SevInf SevInf force-pushed the feat/test-prismaSchemaFolder branch from 0437e53 to e498199 Compare May 31, 2024 12:23
@SevInf
Copy link
Contributor

SevInf commented May 31, 2024

I think getConfig and getSchema are tested enough indirectly by now (+ engine side tests)

@SevInf SevInf marked this pull request as ready for review May 31, 2024 12:38
@SevInf SevInf requested a review from a team as a code owner May 31, 2024 12:38
@SevInf SevInf requested review from Druue and removed request for a team May 31, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants