11import { assert , describe , it } from "@effect/vitest" ;
2- import * as Duration from "effect/Duration" ;
32import * as Effect from "effect/Effect" ;
43import * as FileSystem from "effect/FileSystem" ;
54import * as Layer from "effect/Layer" ;
@@ -19,29 +18,7 @@ import * as DesktopWindow from "../window/DesktopWindow.ts";
1918import * as DesktopWslEnvironment from "../wsl/DesktopWslEnvironment.ts" ;
2019import * as DesktopBackendConfiguration from "./DesktopBackendConfiguration.ts" ;
2120import * as DesktopBackendPool from "./DesktopBackendPool.ts" ;
22- import type { DesktopBackendSnapshot , DesktopBackendStartConfig } from "./DesktopBackendManager.ts" ;
23-
24- function makeStubInstance (
25- id : DesktopBackendPool . BackendInstanceId ,
26- label : string ,
27- ) : DesktopBackendPool . DesktopBackendInstance {
28- const snapshot : DesktopBackendSnapshot = {
29- desiredRunning : false ,
30- ready : false ,
31- activePid : Option . none ( ) ,
32- restartAttempt : 0 ,
33- restartScheduled : false ,
34- } ;
35- return {
36- id,
37- label : Effect . succeed ( label ) ,
38- start : Effect . void ,
39- stop : ( ) => Effect . void ,
40- currentConfig : Effect . succeed ( Option . none < DesktopBackendStartConfig > ( ) ) ,
41- snapshot : Effect . succeed ( snapshot ) ,
42- waitForReady : ( _timeout : Duration . Duration ) => Effect . succeed ( false ) ,
43- } ;
44- }
21+ import type { DesktopBackendStartConfig } from "./DesktopBackendManager.ts" ;
4522
4623function layerPool ( labelRef : Ref . Ref < string > ) : Layer . Layer < DesktopBackendPool . DesktopBackendPool > {
4724 return DesktopBackendPool . layer . pipe (
@@ -111,36 +88,6 @@ function layerPool(labelRef: Ref.Ref<string>): Layer.Layer<DesktopBackendPool.De
11188}
11289
11390describe ( "DesktopBackendPool" , ( ) => {
114- it . effect ( "layerTest exposes registered instances by id" , ( ) =>
115- Effect . gen ( function * ( ) {
116- const pool = yield * DesktopBackendPool . DesktopBackendPool ;
117- const fetchedPrimary = yield * pool . get ( DesktopBackendPool . PRIMARY_INSTANCE_ID ) ;
118- const fetchedWsl = yield * pool . get ( DesktopBackendPool . BackendInstanceId ( "wsl:ubuntu" ) ) ;
119- const fetchedMissing = yield * pool . get ( DesktopBackendPool . BackendInstanceId ( "missing" ) ) ;
120- const all = yield * pool . list ;
121- const resolvedPrimary = yield * pool . primary ;
122-
123- assert . equal ( yield * Option . getOrThrow ( fetchedPrimary ) . label , "Windows" ) ;
124- assert . equal ( yield * Option . getOrThrow ( fetchedWsl ) . label , "WSL (Ubuntu)" ) ;
125- assert . isTrue ( Option . isNone ( fetchedMissing ) ) ;
126- assert . lengthOf ( all , 2 ) ;
127- assert . equal ( resolvedPrimary . id , DesktopBackendPool . PRIMARY_INSTANCE_ID ) ;
128- } ) . pipe (
129- Effect . provide (
130- DesktopBackendPool . layerTest ( [
131- makeStubInstance ( DesktopBackendPool . PRIMARY_INSTANCE_ID , "Windows" ) ,
132- makeStubInstance ( DesktopBackendPool . BackendInstanceId ( "wsl:ubuntu" ) , "WSL (Ubuntu)" ) ,
133- ] ) ,
134- ) ,
135- ) ,
136- ) ;
137-
138- it . effect ( "layerTest dies when no instances are supplied" , ( ) =>
139- Effect . exit (
140- DesktopBackendPool . DesktopBackendPool . pipe ( Effect . provide ( DesktopBackendPool . layerTest ( [ ] ) ) ) ,
141- ) . pipe ( Effect . map ( ( exit ) => assert . equal ( exit . _tag , "Failure" ) ) ) ,
142- ) ;
143-
14491 it . effect ( "resolves the primary label lazily after pool layer construction" , ( ) =>
14592 Effect . scoped (
14693 Effect . gen ( function * ( ) {
0 commit comments