@@ -9,7 +9,9 @@ use std::marker::PhantomData;
99use std:: ops:: Range ;
1010use test_store:: * ;
1111
12- use graph:: components:: store:: { DeploymentLocator , DerivedEntityQuery , WritableStore } ;
12+ use graph:: components:: store:: {
13+ DeploymentLocator , DerivedEntityQuery , SourceableStore , WritableStore ,
14+ } ;
1315use graph:: data:: subgraph:: * ;
1416use graph:: semver:: Version ;
1517use graph:: { entity, prelude:: * } ;
@@ -87,7 +89,14 @@ fn remove_test_data(store: Arc<DieselSubgraphStore>) {
8789/// Test harness for running database integration tests.
8890fn run_test < R , F > ( test : F )
8991where
90- F : FnOnce ( Arc < DieselStore > , Arc < dyn WritableStore > , DeploymentLocator ) -> R + Send + ' static ,
92+ F : FnOnce (
93+ Arc < DieselStore > ,
94+ Arc < dyn WritableStore > ,
95+ Arc < dyn SourceableStore > ,
96+ DeploymentLocator ,
97+ ) -> R
98+ + Send
99+ + ' static ,
91100 R : std:: future:: Future < Output = ( ) > + Send + ' static ,
92101{
93102 run_test_sequentially ( |store| async move {
@@ -102,10 +111,15 @@ where
102111 . writable ( LOGGER . clone ( ) , deployment. id , Arc :: new ( Vec :: new ( ) ) )
103112 . await
104113 . expect ( "we can get a writable store" ) ;
114+ let sourceable = store
115+ . subgraph_store ( )
116+ . sourceable ( LOGGER . clone ( ) , deployment. id , Arc :: new ( Vec :: new ( ) ) )
117+ . await
118+ . expect ( "we can get a writable store" ) ;
105119
106120 // Run test and wait for the background writer to finish its work so
107121 // it won't conflict with the next test
108- test ( store, writable, deployment) . await ;
122+ test ( store, writable, sourceable , deployment) . await ;
109123 } ) ;
110124}
111125
@@ -196,7 +210,7 @@ fn get_with_pending<F>(batch: bool, read_count: F)
196210where
197211 F : Send + Fn ( & dyn WritableStore ) -> i32 + Sync + ' static ,
198212{
199- run_test ( move |store, writable, deployment| async move {
213+ run_test ( move |store, writable, _ , deployment| async move {
200214 let subgraph_store = store. subgraph_store ( ) ;
201215
202216 let read_count = || read_count ( writable. as_ref ( ) ) ;
@@ -294,7 +308,7 @@ fn get_derived_nobatch() {
294308
295309#[ test]
296310fn restart ( ) {
297- run_test ( |store, writable, deployment| async move {
311+ run_test ( |store, writable, _ , deployment| async move {
298312 let subgraph_store = store. subgraph_store ( ) ;
299313 let schema = subgraph_store. input_schema ( & deployment. hash ) . unwrap ( ) ;
300314
@@ -346,6 +360,7 @@ fn restart() {
346360async fn read_range (
347361 store : Arc < Store > ,
348362 writable : Arc < dyn WritableStore > ,
363+ sourceable : Arc < dyn SourceableStore > ,
349364 deployment : DeploymentLocator ,
350365 mutable : bool ,
351366) -> usize {
@@ -367,22 +382,26 @@ async fn read_range(
367382 } else {
368383 & COUNTER2_TYPE
369384 } ;
370- let e = writable . get_range ( et, br) . unwrap ( ) ;
385+ let e = sourceable . get_range ( et, br) . unwrap ( ) ;
371386 e. iter ( ) . map ( |( _, v) | v. iter ( ) ) . flatten ( ) . count ( )
372387}
373388
374389#[ test]
375390fn read_range_mutable ( ) {
376- run_test ( |store, writable, deployment| async move {
377- let num_entities = read_range ( store, writable, deployment, true ) . await ;
378- assert_eq ! ( num_entities, 6 ) // TODO: fix it - it should be 4 as the range is open
379- } )
391+ run_test (
392+ |store, writable, sourceable : Arc < dyn SourceableStore > , deployment| async move {
393+ let num_entities = read_range ( store, writable, sourceable, deployment, true ) . await ;
394+ assert_eq ! ( num_entities, 6 ) // TODO: fix it - it should be 4 as the range is open
395+ } ,
396+ )
380397}
381398
382399#[ test]
383400fn read_range_immutable ( ) {
384- run_test ( |store, writable, deployment| async move {
385- let num_entities = read_range ( store, writable, deployment, false ) . await ;
386- assert_eq ! ( num_entities, 6 ) // TODO: fix it - it should be 4 as the range is open
387- } )
401+ run_test (
402+ |store, writable, sourceable : Arc < dyn SourceableStore > , deployment| async move {
403+ let num_entities = read_range ( store, writable, sourceable, deployment, false ) . await ;
404+ assert_eq ! ( num_entities, 6 ) // TODO: fix it - it should be 4 as the range is open
405+ } ,
406+ )
388407}
0 commit comments