@@ -419,18 +419,29 @@ mod tests {
419419 }
420420
421421 #[ rstest]
422- #[ case( vec![ ] , vec![ KeyValue :: new( "key" , "b" ) ] , "http://schema/a" , None ) ]
423- #[ case( vec![ KeyValue :: new( "key" , "a" ) ] , vec![ KeyValue :: new( "key" , "b" ) ] , "http://schema/a" , Some ( "http://schema/a" ) ) ]
424- fn merge_resource_with_missing_attribtes (
422+ #[ case( vec![ ] , vec![ KeyValue :: new( "key" , "b" ) ] , Some ( "http://schema/a" ) , None , Some ( "http://schema/a" ) ) ]
423+ #[ case( vec![ KeyValue :: new( "key" , "a" ) ] , vec![ KeyValue :: new( "key" , "b" ) ] , Some ( "http://schema/a" ) , None , Some ( "http://schema/a" ) ) ]
424+ #[ case( vec![ KeyValue :: new( "key" , "a" ) ] , vec![ KeyValue :: new( "key" , "b" ) ] , Some ( "http://schema/a" ) , None , Some ( "http://schema/a" ) ) ]
425+ #[ case( vec![ KeyValue :: new( "key" , "a" ) ] , vec![ KeyValue :: new( "key" , "b" ) ] , Some ( "http://schema/a" ) , Some ( "http://schema/b" ) , None ) ]
426+ #[ case( vec![ KeyValue :: new( "key" , "a" ) ] , vec![ KeyValue :: new( "key" , "b" ) ] , None , Some ( "http://schema/b" ) , Some ( "http://schema/b" ) ) ]
427+ fn merge_resource_with_missing_attributes (
425428 #[ case] key_values_a : Vec < KeyValue > ,
426429 #[ case] key_values_b : Vec < KeyValue > ,
427- #[ case] schema_url : & ' static str ,
430+ #[ case] schema_url_a : Option < & ' static str > ,
431+ #[ case] schema_url_b : Option < & ' static str > ,
428432 #[ case] expected_schema_url : Option < & ' static str > ,
429433 ) {
430- let resource = Resource :: from_schema_url ( key_values_a, schema_url) ;
431- let other_resource = Resource :: builder_empty ( )
432- . with_attributes ( key_values_b)
433- . build ( ) ;
434+ let resource = match schema_url_a {
435+ Some ( schema) => Resource :: from_schema_url ( key_values_a, schema) ,
436+ None => Resource :: new ( key_values_a) ,
437+ } ;
438+
439+ let other_resource = match schema_url_b {
440+ Some ( schema) => Resource :: builder_empty ( )
441+ . with_schema_url ( key_values_b, schema)
442+ . build ( ) ,
443+ None => Resource :: new ( key_values_b) ,
444+ } ;
434445
435446 assert_eq ! (
436447 resource. merge( & other_resource) . schema_url( ) ,
@@ -544,15 +555,4 @@ mod tests {
544555 } ,
545556 )
546557 }
547-
548- #[ test]
549- fn with_schema_url_for_empty_attributes ( ) {
550- let resource = Resource :: builder_empty ( )
551- . with_schema_url ( vec ! [ ] , "http://schema/a" )
552- . build ( ) ;
553- assert_eq ! ( resource. schema_url( ) , Some ( "http://schema/a" ) ) ;
554-
555- let resource = Resource :: builder_empty ( ) . build ( ) . merge ( & resource) ;
556- assert_eq ! ( resource. schema_url( ) , Some ( "http://schema/a" ) ) ;
557- }
558558}
0 commit comments