Skip to main content
Glama

Prisma MCP Server

Official
by prisma
Apache 2.0
4
44,213
  • Linux
  • Apple
tests.ts2.58 kB
import { expectTypeOf } from 'expect-type' // @ts-ignore import { Providers } from '../_utils/providers' import testMatrix from './_matrix' import type * as imports from './generated/prisma/client' declare let prisma: imports.PrismaClient declare let loaded: { Plan: typeof imports.Plan } testMatrix.setupTestSuite( ({ provider }) => { test('can create data with an enum value', async () => { const { Plan } = loaded await prisma.user.create({ data: { plan: Plan.CUSTOM, }, }) }) test('can retrieve data with an enum value', async () => { const { Plan } = loaded const user = await prisma.user.create({ data: { plan: Plan.CUSTOM, }, }) const data = await prisma.user.findFirstOrThrow({ where: { id: user.id, plan: Plan.CUSTOM, }, }) expectTypeOf(data.plan).toEqualTypeOf<imports.Plan>() expect(data.plan).toEqual(Plan.CUSTOM) }) test('the enum type can be assigned its own values', () => { const { Plan } = loaded const value: imports.Plan = Plan.CUSTOM expect(value).toEqual(Plan.CUSTOM) expect(value).toEqual('CUSTOM') expectTypeOf(value).toEqualTypeOf<'CUSTOM'>() expectTypeOf<imports.Plan>().toEqualTypeOf<'CUSTOM' | 'FREE' | 'PAID'>() }) testIf(provider == Providers.SQLITE)( 'fails at runtime when an invalid entry is entered manually in SQLite', async () => { // @ts-test-if: provider !== Providers.MONGODB await prisma.$executeRaw`INSERT INTO "User" ("id", "plan") VALUES ('2', 'NONFREE')` const result = await prisma.user.findMany().catch((e) => e) expect(result).toBeInstanceOf(Error) expect(result.message).toMatch(/Value 'NONFREE' not found in enum 'Plan'/) }, ) testIf(provider == Providers.MONGODB)( 'fails at runtime when an invalid entry is entered manually in Mongo', async () => { // @ts-test-if: provider === Providers.MONGODB await prisma.$runCommandRaw({ insert: 'User', documents: [ { _id: '2', plan: 'NONFREE', }, ], }) const result = await prisma.user.findMany().catch((e) => e) expect(result).toBeInstanceOf(Error) expect(result.message).toMatch(/Value 'NONFREE' not found in enum 'Plan'/) }, ) }, { optOut: { from: ['sqlserver'], reason: 'enum values are not supported', }, }, )

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/prisma/prisma'

If you have feedback or need assistance with the MCP directory API, please join our Discord server