Skip to content

Commit

Permalink
Added integration test for checking that a tasks error has values
Browse files Browse the repository at this point in the history
  • Loading branch information
larskristianhaga committed Jul 10, 2024
1 parent bb44f0a commit 33b7c10
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/test/java/com/meilisearch/integration/TasksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,48 @@ public void testClientGetTasksLimit() throws Exception {
assertThat(result.getResults().length, is(notNullValue()));
}

/** Test Get Task Error Values */
@Test
public void testClientGetTaskErrorValues() throws Exception {
String indexUid = "CheckTaskErrorValues";
Index index = client.index(indexUid);

// Deleting all documents from an index that does not exist results in a task error.
TaskInfo taskInfo = index.deleteAllDocuments();
index.waitForTask(taskInfo.getTaskUid());

Task task = client.getTask(taskInfo.getTaskUid());

assertThat(task.getError(), is(notNullValue()));
assertThat(task.getError().getCode(), is(notNullValue()));
assertThat(task.getError().getType(), is(notNullValue()));
assertThat(task.getError().getLink(), is(notNullValue()));
assertThat(task.getError().getMessage(), is(notNullValue()));
}

/** Test Get Task Error Values When Adding Documents */
@Test
public void testClientGetTaskErrorWhenAddingDocuments() throws Exception {
String indexUid = "CheckTaskErrorWhenAddingDocuments";
Index index = client.index(indexUid);

TaskInfo taskInfo = client.createIndex(indexUid);
client.waitForTask(taskInfo.getTaskUid());

String json = "{\"identifyer\": 1, \"name\": \"Donald Duck\"}";
// Adding a document with a wrong identifier results in a task error.
TaskInfo taskInfoAddDocuments = index.addDocuments(json, "identifier");
client.waitForTask(taskInfoAddDocuments.getTaskUid());

Task task = client.getTask(taskInfoAddDocuments.getTaskUid());

assertThat(task.getError(), is(notNullValue()));
assertThat(task.getError().getCode(), is(notNullValue()));
assertThat(task.getError().getType(), is(notNullValue()));
assertThat(task.getError().getLink(), is(notNullValue()));
assertThat(task.getError().getMessage(), is(notNullValue()));
}

/** Test Get Tasks with limit and from */
@Test
public void testClientGetTasksLimitAndFrom() throws Exception {
Expand Down

0 comments on commit 33b7c10

Please sign in to comment.