@@ -570,3 +570,51 @@ async fn tracks_every_url_it_requested() {
570570 vec![ "https://api.example.com/repos/acme/widgets/issues" . to_string( ) ]
571571 ) ;
572572}
573+
574+ #[ tokio:: test]
575+ async fn syncs_in_memory_without_opening_the_configured_path ( ) {
576+ let document = syncables:: load_open_api_document ( flat_document ( Some (
577+ json ! ( [ { "url" : "https://api.example.com" } ] ) ,
578+ ) ) )
579+ . await
580+ . unwrap ( ) ;
581+ let fetch = MockFetch :: default ( ) . respond_json (
582+ "https://api.example.com/repos/acme/widgets/issues" ,
583+ 200 ,
584+ & [ ] ,
585+ json ! ( [
586+ { "number" : 1 , "title" : "First issue" } ,
587+ { "number" : 2 , "title" : "Second issue" }
588+ ] ) ,
589+ ) ;
590+ let client = SyncClient :: new (
591+ config (
592+ Path :: new ( "/this-file-must-never-be-opened" ) ,
593+ & [ ( "owner" , "acme" ) , ( "repo" , "widgets" ) ] ,
594+ ) ,
595+ Arc :: new ( fetch) ,
596+ )
597+ . expect ( "valid config" ) ;
598+
599+ let storage = InMemoryStorage :: new ( ) ;
600+ let report = client
601+ . sync_document ( & document, & storage)
602+ . await
603+ . expect ( "sync succeeds" ) ;
604+
605+ assert ! (
606+ report. errors. is_empty( ) ,
607+ "unexpected errors: {:?}" ,
608+ report. errors
609+ ) ;
610+ assert_eq ! ( report. read. get( "issue" ) , Some ( & 2 ) ) ;
611+ assert_eq ! ( report. ontology_terms, 1 ) ;
612+ assert_eq ! ( storage. ontologies( ) . len( ) , 1 ) ;
613+
614+ let first = storage
615+ . get ( "acme/widgets" , "issue" , "1" )
616+ . await
617+ . expect ( "get succeeds" )
618+ . expect ( "record present" ) ;
619+ assert_eq ! ( first. value. get( "title" ) , Some ( & json!( "First issue" ) ) ) ;
620+ }
0 commit comments