88 prepareSqlNamespaceCatalogSearch ,
99} from "../namespace-completion.js" ;
1010import type {
11+ SqlNamespaceCatalogResolvedContainer ,
1112 SqlNamespaceCatalogSearchRequest ,
1213} from "../namespace-catalog-types.js" ;
1314import type { SqlCatalogEpoch } from "../relation-completion-types.js" ;
@@ -91,12 +92,15 @@ describe("namespace catalog coordinator", () => {
9192 searches . push ( request ) ;
9293 return response ( request ) ;
9394 } ) ;
94- const outcome = await owner . request ( input ( ) ) . result ;
95+ const outcome = await owner . request ( {
96+ ...input ( ) ,
97+ prefix : { quoted : true , value : "ma" } ,
98+ } ) . result ;
9599 expect ( searches ) . toHaveLength ( 1 ) ;
96100 expect ( searches [ 0 ] ) . toMatchObject ( {
97101 dialectId : "duckdb" ,
98102 limit : 10 ,
99- prefix : { value : "ma" } ,
103+ prefix : { quoted : true , value : "ma" } ,
100104 qualifier : [ { value : "memory" } ] ,
101105 scope : "connection" ,
102106 } ) ;
@@ -169,7 +173,7 @@ describe("namespace catalog coordinator", () => {
169173 } ) ;
170174 expect ( signals [ 1 ] ?. aborted ) . toBe ( true ) ;
171175 pending [ 0 ] ?. resolve ( { } ) ;
172- pending [ 1 ] ?. resolve ( { } ) ;
176+ pending [ 1 ] ?. reject ( new Error ( "late" ) ) ;
173177 await Promise . resolve ( ) ;
174178 } ) ;
175179
@@ -188,6 +192,7 @@ describe("namespace catalog coordinator", () => {
188192 const first = owner . request ( input ( "first" ) ) ;
189193 const second = other . owner . request ( input ( "second" ) ) ;
190194 owner . dispose ( ) ;
195+ owner . dispose ( ) ;
191196 await expect ( first . result ) . resolves . toEqual ( {
192197 reason : "disposed" ,
193198 status : "unavailable" ,
@@ -199,6 +204,7 @@ describe("namespace catalog coordinator", () => {
199204 await Promise . resolve ( ) ;
200205 expect ( secondSettled ) . toBe ( false ) ;
201206 coordinator . dispose ( ) ;
207+ coordinator . dispose ( ) ;
202208 await expect ( second . result ) . resolves . toEqual ( {
203209 reason : "disposed" ,
204210 status : "unavailable" ,
@@ -276,10 +282,12 @@ describe("namespace catalog coordinator", () => {
276282 scope : "scope" ,
277283 } ) ;
278284 if ( prepared . status !== "prepared" ) throw new Error ( "prepared" ) ;
279- expect ( await prepared . owner . request ( {
285+ const invalidTicket = prepared . owner . request ( {
280286 ...input ( ) ,
281287 limit : 0 ,
282- } ) . result ) . toMatchObject ( {
288+ } ) ;
289+ invalidTicket . cancel ( ) ;
290+ expect ( await invalidTicket . result ) . toMatchObject ( {
283291 reason : "invalid-request" ,
284292 status : "unavailable" ,
285293 } ) ;
@@ -372,21 +380,38 @@ describe("namespace completion composer", () => {
372380 const catalog = catalogResponse ( ) ;
373381 const main = catalog . containers [ 0 ] ;
374382 if ( ! main ) throw new Error ( "main" ) ;
383+ const parent = main . canonicalPath [ 0 ] ;
384+ const child = main . canonicalPath [ 1 ] ;
385+ if ( ! child ) throw new Error ( "child" ) ;
386+ const copied : SqlNamespaceCatalogResolvedContainer = {
387+ ...main ,
388+ canonicalPath : [
389+ parent ,
390+ { ...child , quoted : true } ,
391+ ] ,
392+ containerEntityId : "main-copy" ,
393+ provenance : {
394+ ...main . provenance ,
395+ containerEntityId : "main-copy" ,
396+ } ,
397+ } ;
398+ const tied : SqlNamespaceCatalogResolvedContainer = {
399+ ...main ,
400+ containerEntityId : "aaa" ,
401+ provenance : {
402+ ...main . provenance ,
403+ containerEntityId : "aaa" ,
404+ } ,
405+ } ;
375406 const duplicated = {
376407 ...readyOutcome ,
377408 response : {
378409 ...catalog ,
379410 containers : [
380411 ...catalog . containers ,
381412 main ,
382- {
383- ...main ,
384- containerEntityId : "main-copy" ,
385- provenance : {
386- ...main . provenance ,
387- containerEntityId : "main-copy" ,
388- } ,
389- } ,
413+ copied ,
414+ tied ,
390415 ] ,
391416 } ,
392417 } ;
@@ -398,7 +423,7 @@ describe("namespace completion composer", () => {
398423 replacementRange : { from : 10 , to : 12 } ,
399424 } ) ;
400425 expect ( all ?. value . items . map ( ( value ) => value . label ) )
401- . toEqual ( [ "main" , "main" , "metrics" ] ) ;
426+ . toEqual ( [ "main" , "main" , "main" , " metrics"] ) ;
402427 const composition = composeSqlNamespaceCompletion ( {
403428 matchPrefix : ( candidate , prefix ) =>
404429 candidate . value . startsWith ( prefix . value )
@@ -421,6 +446,10 @@ describe("namespace completion composer", () => {
421446 edit : { from : 10 , insert : "main" , to : 12 } ,
422447 label : "main" ,
423448 role : "schema" ,
449+ } , {
450+ edit : { from : 10 , insert : "main" , to : 12 } ,
451+ label : "main" ,
452+ role : "schema" ,
424453 } ] ,
425454 } ,
426455 } ) ;
0 commit comments