@@ -100,7 +100,8 @@ impl LinkResolver for TextResolver {
100100 async fn cat ( & self , _ctx : & LinkResolverContext , link : & Link ) -> Result < Vec < u8 > , anyhow:: Error > {
101101 self . texts
102102 . get ( & link. link )
103- . ok_or ( anyhow ! ( "No text for {}" , & link. link) ) . cloned ( )
103+ . ok_or ( anyhow ! ( "No text for {}" , & link. link) )
104+ . cloned ( )
104105 }
105106
106107 async fn get_block (
@@ -1237,6 +1238,23 @@ graft:
12371238 } )
12381239}
12391240
1241+ async fn has_feature_validation_error (
1242+ unvalidated : UnvalidatedSubgraphManifest < Chain > ,
1243+ store : Arc < graph_store_postgres:: SubgraphStore > ,
1244+ ) -> bool {
1245+ unvalidated
1246+ . validate ( store, true )
1247+ . await
1248+ . expect_err ( "Validation must fail" )
1249+ . into_iter ( )
1250+ . any ( |e| {
1251+ matches ! (
1252+ e,
1253+ SubgraphManifestValidationError :: FeatureValidationError ( _)
1254+ )
1255+ } )
1256+ }
1257+
12401258#[ test]
12411259fn declared_grafting_feature_causes_no_feature_validation_errors ( ) {
12421260 const YAML : & str = "
@@ -1254,18 +1272,8 @@ graft:
12541272 test_store:: run_test_sequentially ( |store| async move {
12551273 let store = store. subgraph_store ( ) ;
12561274 let unvalidated = resolve_unvalidated ( YAML ) . await ;
1257- assert ! ( unvalidated
1258- . validate( store. clone( ) , true )
1259- . await
1260- . expect_err( "Validation must fail" )
1261- . into_iter( )
1262- . find( |e| {
1263- matches!(
1264- e,
1265- SubgraphManifestValidationError :: FeatureValidationError ( _)
1266- )
1267- } )
1268- . is_none( ) ) ;
1275+ let has_error = has_feature_validation_error ( unvalidated, store) . await ;
1276+ assert ! ( !has_error, "There must be no FeatureValidationError" ) ;
12691277 let manifest = resolve_manifest ( YAML , SPEC_VERSION_0_0_4 ) . await ;
12701278 assert ! ( manifest. features. contains( & SubgraphFeature :: Grafting ) )
12711279 } )
@@ -1285,18 +1293,8 @@ schema:
12851293 test_store:: run_test_sequentially ( |store| async move {
12861294 let store = store. subgraph_store ( ) ;
12871295 let unvalidated = resolve_unvalidated ( YAML ) . await ;
1288- assert ! ( unvalidated
1289- . validate( store. clone( ) , true )
1290- . await
1291- . expect_err( "Validation must fail" )
1292- . into_iter( )
1293- . find( |e| {
1294- matches!(
1295- e,
1296- SubgraphManifestValidationError :: FeatureValidationError ( _)
1297- )
1298- } )
1299- . is_none( ) ) ;
1296+ let has_error = has_feature_validation_error ( unvalidated, store) . await ;
1297+ assert ! ( !has_error, "There must be no FeatureValidationError" ) ;
13001298
13011299 let manifest = resolve_manifest ( YAML , SPEC_VERSION_0_0_4 ) . await ;
13021300 assert ! ( manifest. features. contains( & SubgraphFeature :: NonFatalErrors ) )
@@ -1339,18 +1337,8 @@ schema:
13391337 . expect ( "Parsing simple manifest works" )
13401338 } ;
13411339
1342- assert ! ( unvalidated
1343- . validate( store. clone( ) , true )
1344- . await
1345- . expect_err( "Validation must fail" )
1346- . into_iter( )
1347- . find( |e| {
1348- matches!(
1349- e,
1350- SubgraphManifestValidationError :: FeatureValidationError ( _)
1351- )
1352- } )
1353- . is_none( ) ) ;
1340+ let has_error = has_feature_validation_error ( unvalidated, store) . await ;
1341+ assert ! ( !has_error, "There must be no FeatureValidationError" ) ;
13541342
13551343 let manifest = resolve_manifest ( YAML , SPEC_VERSION_0_0_4 ) . await ;
13561344 assert ! ( manifest. features. contains( & SubgraphFeature :: FullTextSearch ) )
@@ -1548,18 +1536,8 @@ dataSources:
15481536 . expect ( "Parsing simple manifest works" )
15491537 } ;
15501538
1551- assert ! ( unvalidated
1552- . validate( store. clone( ) , true )
1553- . await
1554- . expect_err( "Validation must fail" )
1555- . into_iter( )
1556- . find( |e| {
1557- matches!(
1558- e,
1559- SubgraphManifestValidationError :: FeatureValidationError ( _)
1560- )
1561- } )
1562- . is_none( ) ) ;
1539+ let has_error = has_feature_validation_error ( unvalidated, store) . await ;
1540+ assert ! ( !has_error, "There must be no FeatureValidationError" ) ;
15631541 } ) ;
15641542}
15651543
@@ -1577,18 +1555,8 @@ schema:
15771555 test_store:: run_test_sequentially ( |store| async move {
15781556 let store = store. subgraph_store ( ) ;
15791557 let unvalidated = resolve_unvalidated ( YAML ) . await ;
1580- assert ! ( unvalidated
1581- . validate( store. clone( ) , true )
1582- . await
1583- . expect_err( "Validation must fail" )
1584- . into_iter( )
1585- . find( |e| {
1586- matches!(
1587- e,
1588- SubgraphManifestValidationError :: FeatureValidationError ( _)
1589- )
1590- } )
1591- . is_none( ) ) ;
1558+ let has_error = has_feature_validation_error ( unvalidated, store) . await ;
1559+ assert ! ( !has_error, "There must be no FeatureValidationError" ) ;
15921560
15931561 let manifest = resolve_manifest ( YAML , SPEC_VERSION_0_0_4 ) . await ;
15941562 assert ! ( manifest. features. contains( & SubgraphFeature :: NonFatalErrors ) )
0 commit comments