Skip to content

Commit

Permalink
Merge #269
Browse files Browse the repository at this point in the history
269: Delete index before creation in test macro r=bidoubiwa a=bidoubiwa

Partial fixes of #238 


Co-authored-by: Charlotte Vermandel <[email protected]>
Co-authored-by: cvermand <[email protected]>
  • Loading branch information
3 people authored Apr 25, 2022
2 parents 08cac64 + 61b2625 commit 4452f2c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions meilisearch-test-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,27 @@ pub fn meilisearch_test(params: TokenStream, input: TokenStream) -> TokenStream
));
}

// And finally if an index was asked we create it and wait until meilisearch confirm its creation.
// We’ll need to delete it later.
// And finally if an index was asked we delete it, and we (re)create it and wait until meilisearch confirm its creation.
if use_index {
outer_block.push(parse_quote!({
let res = client
.delete_index(&name)
.await
.unwrap()
.wait_for_completion(&client, None, None)
.await
.unwrap();
if res.is_failure() {
let error = res.unwrap_failure();
assert_eq!(
error.error_code,
crate::errors::ErrorCode::IndexNotFound,
"{:?}",
error
);
}
}));

outer_block.push(parse_quote!(
let index = client
.create_index(&name, None)
Expand Down

0 comments on commit 4452f2c

Please sign in to comment.