@@ -228,7 +228,20 @@ describe("ModelsDev Service", () => {
228228 } ) ,
229229 )
230230
231- it . live ( "get() returns empty catalog when KV is empty, fetch disabled, and no bundled snapshot is injected" , ( ) =>
231+ it . live ( "get() returns empty catalog when KV is empty, fetch disabled, and the bundled snapshot is disabled" , ( ) =>
232+ Effect . gen ( function * ( ) {
233+ const cache = makeCache ( )
234+ const state = yield * Ref . make ( initialState )
235+ const result = yield * ModelsDev . Service . use ( ( s ) => s . get ( ) ) . pipe (
236+ Effect . provide ( buildLayer ( state , cache , { fetch : false , snapshot : false } ) ) ,
237+ )
238+ expect ( result ) . toEqual ( [ ] )
239+ const final = yield * Ref . get ( state )
240+ expect ( final . calls ) . toEqual ( [ ] )
241+ } ) ,
242+ )
243+
244+ it . live ( "get() falls back to the bundled snapshot when KV is empty and fetch is disabled" , ( ) =>
232245 Effect . gen ( function * ( ) {
233246 const cache = makeCache ( )
234247 const state = yield * Ref . make ( initialState )
@@ -237,7 +250,9 @@ describe("ModelsDev Service", () => {
237250 cache ,
238251 ModelsDev . Service . use ( ( s ) => s . get ( ) ) ,
239252 )
240- expect ( result ) . toEqual ( [ ] )
253+ expect ( result . length ) . toBeGreaterThan ( 0 )
254+ const anthropic = result . find ( ( snapshot ) => snapshot . info . id === "anthropic" )
255+ expect ( anthropic ?. environment ) . toContain ( "ANTHROPIC_API_KEY" )
241256 const final = yield * Ref . get ( state )
242257 expect ( final . calls ) . toEqual ( [ ] )
243258 } ) ,
@@ -248,7 +263,7 @@ describe("ModelsDev Service", () => {
248263 const cache = makeCache ( )
249264 writeCacheText ( cache , "{" )
250265 const state = yield * Ref . make ( { ...initialState , body : JSON . stringify ( fixture2 ) } )
251- const context = yield * Layer . build ( buildLayer ( state , cache , { fetch : true } ) )
266+ const context = yield * Layer . build ( buildLayer ( state , cache , { fetch : true , snapshot : false } ) )
252267 const result = yield * ModelsDev . Service . use ( ( s ) => s . get ( ) ) . pipe ( Effect . provide ( context ) )
253268 expect ( result ) . toEqual ( fixture2Snapshot )
254269 expect ( cache . values . get ( cacheKey ) ) . toMatchObject ( { body : JSON . stringify ( fixture2 ) } )
@@ -263,7 +278,7 @@ describe("ModelsDev Service", () => {
263278 const state = yield * Ref . make ( { ...initialState , body : JSON . stringify ( fixture2 ) } )
264279 const layer = Layer . fresh (
265280 AppNodeBuilder . build ( ModelsDev . node , [
266- [ ModelsDev . node , ModelsDev . configured ( { fetch : true } ) ] ,
281+ [ ModelsDev . node , ModelsDev . configured ( { fetch : true , snapshot : false } ) ] ,
267282 [ LayerNodePlatform . httpClient , Layer . succeed ( HttpClient . HttpClient , makeMockClient ( state ) ) ] ,
268283 [ KV . node , makeFailingWriteKV ( cache ) ] ,
269284 ] ) ,
@@ -281,7 +296,7 @@ describe("ModelsDev Service", () => {
281296 const cache = makeCache ( )
282297 const state = yield * Ref . make ( initialState )
283298 yield * ModelsDev . Service . use ( ( service ) => service . get ( ) ) . pipe (
284- Effect . provide ( buildLayer ( state , cache , { url : "" , fetch : true } ) ) ,
299+ Effect . provide ( buildLayer ( state , cache , { url : "" , fetch : true , snapshot : false } ) ) ,
285300 )
286301 expect ( ( yield * Ref . get ( state ) ) . calls [ 0 ] ?. url ) . toBe ( "https://models.opencode.ai/api.json" )
287302 } ) ,
@@ -296,7 +311,7 @@ describe("ModelsDev Service", () => {
296311 return yield * Effect . all ( [ svc . get ( ) , svc . get ( ) , svc . get ( ) , svc . get ( ) , svc . get ( ) ] , {
297312 concurrency : "unbounded" ,
298313 } )
299- } ) . pipe ( Effect . provide ( buildLayer ( state , cache , { fetch : true } ) ) )
314+ } ) . pipe ( Effect . provide ( buildLayer ( state , cache , { fetch : true , snapshot : false } ) ) )
300315 for ( const result of results ) expect ( result ) . toEqual ( fixtureSnapshot )
301316 expect ( ( yield * Ref . get ( state ) ) . calls . length ) . toBe ( 1 )
302317 } ) ,
0 commit comments