11import { describe , expect , it } from "@effect/vitest" ;
22
33import { createExecutor } from "./promise" ;
4- import { collectTables } from "./executor" ;
54import { definePlugin , tool } from "./plugin" ;
65import { createSqliteTestFumaDb } from "./sqlite-test-db" ;
76import { Effect , Schema } from "effect" ;
@@ -38,12 +37,12 @@ const echoPlugin = definePlugin(() => ({
3837describe ( "promise/createExecutor" , ( ) => {
3938 it ( "returns Promise-shaped executor and invokes static tools" , async ( ) => {
4039 const plugins = [ echoPlugin ( ) ] as const ;
41- const db = await createSqliteTestFumaDb ( {
42- tables : collectTables ( plugins ) ,
43- namespace : "executor_promise_test" ,
44- } ) ;
4540 const executor = await createExecutor ( {
46- db : db . db ,
41+ db : ( { tables } ) =>
42+ createSqliteTestFumaDb ( {
43+ tables,
44+ namespace : "executor_promise_test" ,
45+ } ) ,
4746 plugins,
4847 onElicitation : "accept-all" ,
4948 } ) ;
@@ -55,17 +54,16 @@ describe("promise/createExecutor", () => {
5554 expect ( out ) . toBe ( "hi" ) ;
5655
5756 await executor . close ( ) ;
58- await db . close ( ) ;
5957 } ) ;
6058
6159 it ( "promisifies plugin extension methods" , async ( ) => {
6260 const plugins = [ echoPlugin ( ) ] as const ;
63- const db = await createSqliteTestFumaDb ( {
64- tables : collectTables ( plugins ) ,
65- namespace : "executor_promise_test" ,
66- } ) ;
6761 const executor = await createExecutor ( {
68- db : db . db ,
62+ db : ( { tables } ) =>
63+ createSqliteTestFumaDb ( {
64+ tables,
65+ namespace : "executor_promise_test" ,
66+ } ) ,
6967 plugins,
7068 onElicitation : "accept-all" ,
7169 } ) ;
@@ -74,7 +72,6 @@ describe("promise/createExecutor", () => {
7472 expect ( greeting ) . toBe ( "hello, world" ) ;
7573
7674 await executor . close ( ) ;
77- await db . close ( ) ;
7875 } ) ;
7976
8077 it ( "per-invoke onElicitation override wins over the executor-level default" , async ( ) => {
@@ -107,12 +104,12 @@ describe("promise/createExecutor", () => {
107104 } ) ) ;
108105
109106 const plugins = [ approvedPlugin ( ) ] as const ;
110- const db = await createSqliteTestFumaDb ( {
111- tables : collectTables ( plugins ) ,
112- namespace : "executor_promise_test" ,
113- } ) ;
114107 const executor = await createExecutor ( {
115- db : db . db ,
108+ db : ( { tables } ) =>
109+ createSqliteTestFumaDb ( {
110+ tables,
111+ namespace : "executor_promise_test" ,
112+ } ) ,
116113 plugins,
117114 onElicitation : "accept-all" , // default → auto-approve
118115 } ) ;
@@ -137,6 +134,5 @@ describe("promise/createExecutor", () => {
137134 } ) ;
138135
139136 await executor . close ( ) ;
140- await db . close ( ) ;
141137 } ) ;
142138} ) ;
0 commit comments