From e95cec7ea67d3e641413cadc5c1817e474534080 Mon Sep 17 00:00:00 2001 From: mpostma Date: Mon, 1 Jun 2020 11:06:57 +0200 Subject: [PATCH] add test for error_code --- meilisearch-http/tests/index.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/meilisearch-http/tests/index.rs b/meilisearch-http/tests/index.rs index ed67f2d1d..be8193613 100644 --- a/meilisearch-http/tests/index.rs +++ b/meilisearch-http/tests/index.rs @@ -54,7 +54,7 @@ async fn create_index_with_uid() { "uid": "movies", }); - let (res1_value, status_code) = server.create_index(body).await; + let (res1_value, status_code) = server.create_index(body.clone()).await; assert_eq!(status_code, 201); assert_eq!(res1_value.as_object().unwrap().len(), 5); @@ -67,6 +67,13 @@ async fn create_index_with_uid() { assert!(r1_created_at.len() > 1); assert!(r1_updated_at.len() > 1); + // 1.5 verify that error is thrown when trying to create the same index + + let (response, status_code) = server.create_index(body).await; + + assert_eq!(status_code, 400); + assert_eq!(response["errorCode"].as_str().unwrap(), "index_already_exists"); + // 2 - Check the list of indexes let (res2_value, status_code) = server.list_indexes().await;