From 315165e160b473804dab5bbf3ab22f57c6d4905a Mon Sep 17 00:00:00 2001 From: farreldarian Date: Tue, 25 Jun 2024 00:36:28 +0700 Subject: [PATCH] test: unuse bun-specific apis --- bun.lockb | Bin 316800 -> 317192 bytes packages/usage/package.json | 4 ++-- packages/usage/src/lib/sqlite.ts | 4 ++-- .../usage/tests/configure-date-mode.test.ts | 15 ++++++++------- .../usage/tests/single-file-output.test.ts | 12 ++++++------ 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/bun.lockb b/bun.lockb index ba5796431b89be6dfcd622e411259e2ed9395ae1..ece21b8e5bab2a4939fd3fcf14f100c1b1ec31ea 100755 GIT binary patch delta 5637 zcmeHLYgkoP8eV&^bBc{2A}Sn?1PCgiAP4kp^lWCAgb!y5khMJ;@0t(*1TZ*B9j;WQ-yx-pYIQ_7H)6AdF^StN%-gm9_ zt;=5foV9o5U;P(u_J1ih>eN%iMt`6E!l=~p{-1t!CS&i#PZorJI;&eyV}ETz_~uTp zIfpEaKHAs~^8wE;EGsB2V{BP7WB$Dvcg&ArN!m!(P{aGG_|g+ zhELth&Y!^^D<~+ADJYr2P5+-QjQOHnuG#B$FJoHK(BAOFnzfAq&af`08M_zq+$qK) zz~RM=g@UbM@@q6H@LEt(8)My}0@0Y(#@A$L$CmE4rMl%~y0aVa+ujYN%L%`sk8vT+%bb=B!orPs8=v#H84cq#C#T6MB&4LZiy zP_0UJNfWfFuT!nBK*wuU=`Lj#q9oLlw9ZqB7F>p5dI!0PXb!;|QYx#UMnG|`BvVz| zpW1XPOAE?u?u#>GjZzO1>3FhNXf zDMfngk~~$Zfr^8&Xw~{>Sc}+RoP+IlxVb8ev+{< zS{1TqA~MESjgh_xMT@NHW7`2m%iyJTrm5Dhr#$O00TGP>%c!c-pR~gERBIIW%LCfX zc9->eM0t92{I-{PhOr5{_adT)^yoaILOmLPma%+2`a2?{)c0$~rt02oLL>YP%dcjlr z7$U>lgvh9O`F5%E8&ByxMEB`!_uTfnw`1Sx-eg2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9jO?Db7<~)%32BHtJWU`1F4sKX-g_tLM9q@mrE!n5aCneZ2C$ z%t?{nA6y@uGJo-Lp7+O>@YFr2#IEz59?JJD{GuF8jxdqynHeU0l!2qITgxtV;a=fD zfyW&o4#)%fNrInXI?)gWP63ut$siFB&v!ab^+Qd*LyZLLEzjTb@MtELd)5vT6*hIS zIrfU-v}S}D>dA}|EwVp9nDO|9KoNz;iVXE$gdsqvr!-c~6Lx+UdV&tciQq*3g8LBQ z=N*1z;>WQ$KshiM;G3}v;K#d1J(2OEuM*3*1%3`%1FQws0lNYIa+?8^0+pT#38Jqo z&+?QE6H{clfNB%P0tYXC8Ne(382AME6yR0v2M*8#r}%TPzaf0xPHj%{kX=W-ijszl zV8>q&{uOu?SP#4gYykKU&v*Zsp331OT2_af`_ePUgMIl!fWra34%^LJy$ZM&_!xRO zkc@b}CpKSfl56%r9|O(-lW+k-(C-Vx!QddEKhO_23-3!H5q;ahp96=0(?BcmPhcPL z3GlDm{enohhD&_KLTC<$OvxB)*97zSHpUFF(5=*!{jDPaEMJ>BMj2 zh87xhScF7)KfSvbpZxH^*c*>4a*}ftCrD>o=%K?RIl}vN`8$ZS@F(cGZip|r1Aq$>68bh8=bTJO4+ z7M_29<0D^h%Eh>;=7t4&FjA2$&!;C_ghS4zwJpMpX+*V(PPvBEHZd+@!)Zwxf_-_( z9Z~$$qRVkMIn|kz#@oI3G|g`lOO-1fp6}blTt(@=NHdR%HQ?khz&|x4siJ{CXtc%9$wpg9?;Vy| n*l43E?IMgKn{3;B7hA6;S2R*vlP$Y2|((#* { test('global config', async () => { const temp = await tempHandler.prepare() - await Bun.write( + fs.writeFileSync( getSchemaPath(temp), `datasource db { provider = "postgresql" @@ -28,9 +29,9 @@ test('global config', async () => { date DateTime }` ) - await $`bun prisma generate --schema ${getSchemaPath(temp)}`.quiet() + execSync(`bun prisma generate --schema ${getSchemaPath(temp)}`) - const output = await Bun.file(`${temp.basePath}/drizzle.ts`).text() + const output = fs.readFileSync(`${temp.basePath}/drizzle.ts`, 'utf-8') expect(output).toContain( "date: timestamp('date', { mode: 'string', precision: 3 })" ) @@ -39,7 +40,7 @@ test('global config', async () => { test('field-level config', async () => { const temp = await tempHandler.prepare() - await Bun.write( + fs.writeFileSync( getSchemaPath(temp), `datasource db { provider = "postgresql" @@ -58,9 +59,9 @@ test('field-level config', async () => { stringDate DateTime }` ) - await $`bun prisma generate --schema ${getSchemaPath(temp)}`.quiet() + execSync(`bun prisma generate --schema ${getSchemaPath(temp)}`) - const output = await Bun.file(`${temp.basePath}/drizzle.ts`).text() + const output = await fs.readFileSync(`${temp.basePath}/drizzle.ts`, 'utf-8') expect(output).toContain( "normalDate: timestamp('normalDate', { mode: 'date', precision: 3 })" ) diff --git a/packages/usage/tests/single-file-output.test.ts b/packages/usage/tests/single-file-output.test.ts index 996820f..112be07 100644 --- a/packages/usage/tests/single-file-output.test.ts +++ b/packages/usage/tests/single-file-output.test.ts @@ -1,5 +1,5 @@ +import { execSync } from 'node:child_process' import fs from 'node:fs' -import { $ } from 'bun' import { createTempHandler } from './utils/temp' const tempHandler = createTempHandler() @@ -11,7 +11,7 @@ afterAll(() => { test('generates drizzle.ts', async () => { const temp = await tempHandler.prepare() writeSchemaWithOutput(temp.name, 'drizzle.ts') - await $`bun prisma generate --schema .temp/${temp.name}/schema.prisma`.quiet() + execSync(`bun prisma generate --schema .temp/${temp.name}/schema.prisma`) expect(fs.existsSync(`.temp/${temp.name}/drizzle.ts`)).toBe(true) }) @@ -19,7 +19,7 @@ test('generates drizzle.ts', async () => { test('generates ./drizzle.ts', async () => { const temp = await tempHandler.prepare() writeSchemaWithOutput(temp.name, './drizzle.ts') - await $`bun prisma generate --schema .temp/${temp.name}/schema.prisma`.quiet() + execSync(`bun prisma generate --schema .temp/${temp.name}/schema.prisma`) expect(fs.existsSync(`.temp/${temp.name}/drizzle.ts`)).toBe(true) }) @@ -27,7 +27,7 @@ test('generates ./drizzle.ts', async () => { test('generates sub/drizzle.ts', async () => { const temp = await tempHandler.prepare() writeSchemaWithOutput(temp.name, 'sub/drizzle.ts') - await $`bun prisma generate --schema .temp/${temp.name}/schema.prisma`.quiet() + execSync(`bun prisma generate --schema .temp/${temp.name}/schema.prisma`) expect(fs.existsSync(`.temp/${temp.name}/sub/drizzle.ts`)).toBe(true) }) @@ -35,7 +35,7 @@ test('generates sub/drizzle.ts', async () => { test('generates ./sub/drizzle.ts', async () => { const temp = await tempHandler.prepare() writeSchemaWithOutput(temp.name, './sub/drizzle.ts') - await $`bun prisma generate --schema .temp/${temp.name}/schema.prisma`.quiet() + execSync(`bun prisma generate --schema .temp/${temp.name}/schema.prisma`) expect(fs.existsSync(`.temp/${temp.name}/sub/drizzle.ts`)).toBe(true) }) @@ -43,7 +43,7 @@ test('generates ./sub/drizzle.ts', async () => { test('generates ./sub/multi/drizzle.ts', async () => { const temp = await tempHandler.prepare() writeSchemaWithOutput(temp.name, './sub/multi/drizzle.ts') - await $`bun prisma generate --schema .temp/${temp.name}/schema.prisma`.quiet() + execSync(`bun prisma generate --schema .temp/${temp.name}/schema.prisma`) expect(fs.existsSync(`.temp/${temp.name}/sub/multi/drizzle.ts`)).toBe(true) })