@@ -11,7 +11,6 @@ import { HttpClient, HttpClientResponse } from "effect/http";
1111import { ChildProcessSpawner } from "effect/process" ;
1212
1313import * as ServerSecretStore from "../auth/ServerSecretStore.ts" ;
14- import { CLOUD_ENDPOINT_RUNTIME_CONFIG } from "./config.ts" ;
1514import * as ConnectReachability from "./ConnectReachability.ts" ;
1615import * as ManagedEndpointRuntime from "./ManagedEndpointRuntime.ts" ;
1716
@@ -71,17 +70,6 @@ describe("classifyReachability", () => {
7170 ) . toMatchObject ( { cause : "dns_failed" } ) ;
7271 } ) ;
7372
74- it ( "gives the MCP URL on the host the running tunnel answered on" , ( ) => {
75- const result = ConnectReachability . classifyReachability (
76- facts ( { endpoint : { kind : "status" , status : 200 } } ) ,
77- checkedAt ,
78- ) ;
79- expect ( result ) . toMatchObject ( { status : "reachable" , hostname : "env.example.test" } ) ;
80- expect ( result . status === "reachable" && connectReachableMcpUrl ( result ) ) . toBe (
81- "https://env.example.test/mcp" ,
82- ) ;
83- } ) ;
84-
8573 it ( "waits on a connector that has not connected while the edge answers" , ( ) => {
8674 expect (
8775 ConnectReachability . classifyReachability (
@@ -93,53 +81,35 @@ describe("classifyReachability", () => {
9381} ) ;
9482
9583describe ( "ConnectReachability" , ( ) => {
96- it . effect ( "drops a result once the tunnel config it checked is replaced" , ( ) => {
97- const secrets = new Map ( [ [ CLOUD_ENDPOINT_RUNTIME_CONFIG , new TextEncoder ( ) . encode ( "first" ) ] ] ) ;
98- const unused = Effect . die ( "unused" ) ;
84+ it . effect ( "exposes the checked tunnel's MCP URL until its config changes" , ( ) => {
85+ let config = new TextEncoder ( ) . encode ( "first" ) ;
9986 const dependencies = Layer . mergeAll (
100- Layer . succeed (
101- ServerSecretStore . ServerSecretStore ,
102- ServerSecretStore . ServerSecretStore . of ( {
103- get : ( name ) => Effect . sync ( ( ) => Option . fromNullishOr ( secrets . get ( name ) ) ) ,
104- set : ( ) => unused ,
105- create : ( ) => unused ,
106- getOrCreateRandom : ( ) => unused ,
107- remove : ( ) => unused ,
108- } ) ,
109- ) ,
110- Layer . succeed (
111- ManagedEndpointRuntime . CloudManagedEndpointRuntime ,
112- ManagedEndpointRuntime . CloudManagedEndpointRuntime . of ( {
113- applyConfig : ( ) => unused ,
114- inspectConnector : Effect . succeed ( connected ) ,
115- readinessChanged : Stream . empty ,
116- recoveryRequests : Stream . empty ,
117- requestRecovery : ( ) => unused ,
118- tunnelConnected : Stream . empty ,
119- withLinkStateLock : ( effect ) => effect ,
120- } ) ,
121- ) ,
87+ Layer . mock ( ServerSecretStore . ServerSecretStore ) ( {
88+ get : ( ) => Effect . sync ( ( ) => Option . some ( config ) ) ,
89+ } ) ,
90+ Layer . mock ( ManagedEndpointRuntime . CloudManagedEndpointRuntime ) ( {
91+ inspectConnector : Effect . succeed ( connected ) ,
92+ readinessChanged : Stream . empty ,
93+ } ) ,
12294 Layer . succeed (
12395 HttpClient . HttpClient ,
12496 HttpClient . make ( ( request ) =>
12597 Effect . succeed ( HttpClientResponse . fromWeb ( request , new Response ( "{}" ) ) ) ,
12698 ) ,
12799 ) ,
128- Layer . succeed (
129- ChildProcessSpawner . ChildProcessSpawner ,
130- ChildProcessSpawner . make ( ( ) => unused ) ,
131- ) ,
100+ Layer . mock ( ChildProcessSpawner . ChildProcessSpawner ) ( { } ) ,
132101 ) ;
133102
134103 return Effect . gen ( function * ( ) {
135104 const reachability = yield * ConnectReachability . ConnectReachability ;
136105 yield * reachability . check ;
137- expect ( Option . getOrNull ( yield * reachability . latest ) ) . toMatchObject ( {
138- hostname : "env.example.test" ,
139- } ) ;
106+ const result = Option . getOrThrow ( yield * reachability . latest ) ;
107+ expect ( result . status === "reachable" && connectReachableMcpUrl ( result ) ) . toBe (
108+ "https://env.example.test/mcp" ,
109+ ) ;
140110
141111 // A relink stores a new tunnel before its connector reports in.
142- secrets . set ( CLOUD_ENDPOINT_RUNTIME_CONFIG , new TextEncoder ( ) . encode ( "second" ) ) ;
112+ config = new TextEncoder ( ) . encode ( "second" ) ;
143113 expect ( yield * reachability . latest ) . toEqual ( Option . none ( ) ) ;
144114 } ) . pipe ( Effect . provide ( ConnectReachability . layer . pipe ( Layer . provide ( dependencies ) ) ) ) ;
145115 } ) ;
0 commit comments