elastic / elasticsearch-rs

Official Elasticsearch Rust Client
https://www.elastic.co/guide/en/elasticsearch/client/rust-api/current/index.html
Apache License 2.0
695 stars 70 forks source link

Fix API generator tests #135

Closed russcam closed 3 years ago

russcam commented 3 years ago

This commit adds back the ast_eq function that is used in api_generator tests to test Tokens equality.

Ignore the api_generator tests that use ast_eq for now since the removal of rustfmt-nightly crate results in Tokens that are slightly different regarding whitespace tokens around generic type parameters

"impl < \'b > SearchParts < \'b > { # [ doc = \"Builds a relative URL path to the Search API\" ] pub fn url ( self ) -> Cow < \'static , str > { match self { SearchParts :: None => \"/_search\" . into ( ) , SearchParts :: I
ndex ( ref index ) => { let index_str = index . join ( \",\" ) ; let encoded_index : Cow < str > = percent_encode ( index_str . as_bytes ( ) , PARTS_ENCODED ) . into ( ) ; let mut p = String :: with_capacity ( 9usize + encoded_index
 . len ( ) ) ; p . push_str ( \"/\" ) ; p . push_str ( encoded_index . as_ref ( ) ) ; p . push_str ( \"/_search\" ) ; p . into ( ) } SearchParts :: IndexType ( ref index , ref ty ) => { let index_str = index . join ( \",\" ) ; let t
y_str = ty . join ( \",\" ) ; let encoded_index : Cow < str > = percent_encode ( index_str . as_bytes ( ) , PARTS_ENCODED ) . into ( ) ; let encoded_ty : Cow < str > = percent_encode ( ty_str . as_bytes ( ) , PARTS_ENCODED ) . into
( ) ; let mut p = String :: with_capacity ( 10usize + encoded_index . len ( ) + encoded_ty . len ( ) ) ; p . push_str ( \"/\" ) ; p . push_str ( encoded_index . as_ref ( ) ) ; p . push_str ( \"/\" ) ; p . push_str ( encoded_ty . as_
ref ( ) ) ; p . push_str ( \"/_search\" ) ; p . into ( ) } } } }"

compared to

"impl < \'b > SearchParts < \'b > { # [ doc = \"Builds a relative URL path to the Search API\" ] pub fn url ( self ) -> Cow<\'static, str> { match self { SearchParts :: None => \"/_search\" . into ( ) , SearchParts :: Index
 ( ref index ) => { let index_str = index . join ( \",\" ) ; let encoded_index : Cow < str > = percent_encode ( index_str . as_bytes ( ) , PARTS_ENCODED ) . into ( ) ; let mut p = String :: with_capacity ( 9usize + encoded_index . l
en ( ) ) ; p . push_str ( \"/\" ) ; p . push_str ( encoded_index . as_ref ( ) ) ; p . push_str ( \"/_search\" ) ; p . into ( ) } SearchParts :: IndexType ( ref index , ref ty ) => { let index_str = index . join ( \",\" ) ; let ty_st
r = ty . join ( \",\" ) ; let encoded_index : Cow < str > = percent_encode ( index_str . as_bytes ( ) , PARTS_ENCODED ) . into ( ) ; let encoded_ty : Cow < str > = percent_encode ( ty_str . as_bytes ( ) , PARTS_ENCODED ) . into ( )
; let mut p = String :: with_capacity ( 10usize + encoded_index . len ( ) + encoded_ty . len ( ) ) ; p . push_str ( \"/\" ) ; p . push_str ( encoded_index . as_ref ( ) ) ; p . push_str ( \"/\" ) ; p . push_str ( encoded_ty . as_ref
( ) ) ; p . push_str ( \"/_search\" ) ; p . into ( ) } } } }"