@@ -14,6 +14,7 @@ import * as Path from "effect/Path";
1414import * as Redacted from "effect/Redacted" ;
1515import * as Result from "effect/Result" ;
1616import * as Schema from "effect/Schema" ;
17+ import * as TestClock from "effect/testing/TestClock" ;
1718import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner" ;
1819import { HttpClient , HttpClientError , HttpClientResponse } from "effect/http" ;
1920
@@ -115,7 +116,12 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
115116 const first = yield * makeExecutable ( "runtime 'one" ) ;
116117 const second = yield * makeExecutable ( "runtime two" ) ;
117118 const signedOut = yield * makeExecutable ( "runtime signed-out" , true ) ;
118- const controls = { selected : first , failResolution : false , beforeAcquire : Effect . void } ;
119+ const controls = {
120+ selected : first ,
121+ failResolution : false ,
122+ beforeAcquire : Effect . void ,
123+ metadataServer : options . metadataServer ?? false ,
124+ } ;
119125 const acquisitions : Array < { binaryPath : string | undefined ; path : string | undefined } > = [ ] ;
120126 const releases : Array < string | null > = [ ] ;
121127 const launches : Array < {
@@ -169,7 +175,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
169175 return Effect . die ( "Unexpected quota request" ) ;
170176 }
171177 metadataRequests . push ( request . url ) ;
172- return options . metadataServer
178+ return controls . metadataServer
173179 ? Effect . succeed (
174180 HttpClientResponse . fromWeb (
175181 request ,
@@ -433,12 +439,19 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
433439 { name : "GCE_METADATA_HOST" , value : "metadata.internal:8080" } ,
434440 ] ,
435441 metadataHost : "metadata.internal:8080" ,
436- metadataServer : true ,
442+ metadataServer : false ,
437443 } ) ;
444+ const error = yield * h . refresh ( ) . pipe ( Effect . flip ) ;
445+ expect ( error . detail ) . toContain ( "gcloud auth application-default login" ) ;
446+ h . controls . metadataServer = true ;
447+ yield * TestClock . adjust ( "30 seconds" ) ;
438448 yield * h . refresh ( ) ;
439449 yield * h . refresh ( ) ;
440450 expect ( ( yield * h . instance . snapshot . getSnapshot ) . auth . status ) . toBe ( "authenticated" ) ;
441- expect ( h . metadataRequests ) . toEqual ( [ "http://metadata.internal:8080" ] ) ;
451+ expect ( h . metadataRequests ) . toEqual ( [
452+ "http://metadata.internal:8080" ,
453+ "http://metadata.internal:8080" ,
454+ ] ) ;
442455 yield * h . assertClosed ;
443456 } ) . pipe ( Effect . scoped ) ,
444457 ) ;
0 commit comments