Skip to content

Commit 4452f2c

Browse files
bors[bot]bidoubiwa
andauthored
Merge #269
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]>
2 parents 08cac64 + 61b2625 commit 4452f2c

File tree

1 file changed

+20
-2
lines changed
  • meilisearch-test-macro/src

1 file changed

+20
-2
lines changed

meilisearch-test-macro/src/lib.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,27 @@ pub fn meilisearch_test(params: TokenStream, input: TokenStream) -> TokenStream
9595
));
9696
}
9797

98-
// And finally if an index was asked we create it and wait until meilisearch confirm its creation.
99-
// We’ll need to delete it later.
98+
// And finally if an index was asked we delete it, and we (re)create it and wait until meilisearch confirm its creation.
10099
if use_index {
100+
outer_block.push(parse_quote!({
101+
let res = client
102+
.delete_index(&name)
103+
.await
104+
.unwrap()
105+
.wait_for_completion(&client, None, None)
106+
.await
107+
.unwrap();
108+
if res.is_failure() {
109+
let error = res.unwrap_failure();
110+
assert_eq!(
111+
error.error_code,
112+
crate::errors::ErrorCode::IndexNotFound,
113+
"{:?}",
114+
error
115+
);
116+
}
117+
}));
118+
101119
outer_block.push(parse_quote!(
102120
let index = client
103121
.create_index(&name, None)

0 commit comments

Comments
 (0)