@@ -538,16 +538,18 @@ it.layer(NodeServices.layer)("PluginCatalog", (it) => {
538538
539539 describe ( "interrupted management" , ( ) => {
540540 /** An approved, enabled installation in a catalogue that can be restarted on the same database. */
541- const enabledInStub = Effect . fn ( "enabledInStub" ) ( function * ( ) {
541+ const enabledInStub = Effect . fn ( "enabledInStub" ) ( function * (
542+ fileSystem ?: FileSystem . FileSystem ,
543+ ) {
542544 const stub = yield * makeStubSupervisor ;
543545 const before = yield * Scope . make ( ) ;
544- const catalog = yield * startStubCatalog ( before , stub . service ) ;
546+ const catalog = yield * startStubCatalog ( before , stub . service , fileSystem ) ;
545547 const plugin = yield * preparePlugin ( "test.interrupted" ) ;
546548 const { installation } = yield * catalog . add ( { directory : plugin . directory } ) ;
547549 const installationId = installation . installationId ;
548550 yield * catalog . consent ( { installationId, digest : installation . source ! . digest } ) ;
549551 yield * catalog . enable ( { installationId } ) ;
550- return { stub, before, catalog, installationId } ;
552+ return { stub, before, catalog, installationId, directory : installation . directory } ;
551553 } ) ;
552554
553555 /** Starts the catalogue again and waits until its startup re-registration has run. */
@@ -622,6 +624,37 @@ it.layer(NodeServices.layer)("PluginCatalog", (it) => {
622624 ) ,
623625 ) ;
624626
627+ it . effect ( "waits for an interrupted stop before inspecting and enabling again" , ( ) =>
628+ withDatabase (
629+ Effect . gen ( function * ( ) {
630+ const fs = yield * makeHoldingFileSystem ;
631+ const { stub, catalog, installationId, directory } = yield * enabledInStub ( fs . fileSystem ) ;
632+ const stopping = yield * makeHold ;
633+ stub . holds . disable = stopping ;
634+ const disabling = yield * catalog
635+ . disable ( { installationId } )
636+ . pipe ( Effect . forkChild ( { startImmediately : true } ) ) ;
637+ yield * Deferred . await ( stopping . reached ) ;
638+ yield * Fiber . interrupt ( disabling ) ;
639+
640+ const inspection = yield * fs . holdDirectory ( directory ) ;
641+ const enabling = yield * catalog
642+ . enable ( { installationId } )
643+ . pipe ( Effect . forkChild ( { startImmediately : true } ) ) ;
644+ const inspectedBeforeStop = yield * Deferred . isDone ( inspection . reached ) ;
645+ expect ( stub . registrations . size ) . toBe ( 0 ) ;
646+
647+ yield * Deferred . succeed ( stopping . release , undefined ) ;
648+ yield * Deferred . await ( inspection . reached ) ;
649+ yield * Deferred . succeed ( inspection . release , undefined ) ;
650+ const { installation } = yield * Fiber . join ( enabling ) ;
651+ expect ( inspectedBeforeStop ) . toBe ( false ) ;
652+ expect ( installation ) . toMatchObject ( { enabled : true , generation : 2 } ) ;
653+ expect ( stub . registrations . size ) . toBe ( 1 ) ;
654+ } ) ,
655+ ) ,
656+ ) ;
657+
625658 it . effect ( "keeps a remove whose caller left while the process stopped" , ( ) =>
626659 withDatabase (
627660 Effect . gen ( function * ( ) {
0 commit comments