Skip to content

Commit

Permalink
ES8 : fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
romainruaud committed Feb 22, 2023
1 parent 360e8c4 commit f9ecaeb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ protected function setUp(): void
$error1 = ['type' => 'reason1', 'reason' => 'Reason 1'];
$error2 = ['type' => 'reason2', 'reason' => 'Reason 2'];
$items = [
['index' => ['_index' => 'index', '_type' => 'type', '_id' => 'doc1']],
['index' => ['_index' => 'index', '_type' => 'type', '_id' => 'doc2']],
['index' => ['_index' => 'index', '_type' => 'type', '_id' => 'doc3', 'error' => $error1]],
['index' => ['_index' => 'index', '_type' => 'type', '_id' => 'doc4', 'error' => $error1]],
['index' => ['_index' => 'index', '_type' => 'type', '_id' => 'doc5', 'error' => $error2]],
['index' => ['_index' => 'index', '_type' => 'type', '_id' => 'doc6', 'error' => $error2]],
['index' => ['_index' => 'index', '_id' => 'doc1']],
['index' => ['_index' => 'index', '_id' => 'doc2']],
['index' => ['_index' => 'index', '_id' => 'doc3', 'error' => $error1]],
['index' => ['_index' => 'index', '_id' => 'doc4', 'error' => $error1]],
['index' => ['_index' => 'index', '_id' => 'doc5', 'error' => $error2]],
['index' => ['_index' => 'index', '_id' => 'doc6', 'error' => $error2]],
];
$this->bulkResponse = new BulkResponse(['errors' => true, 'items' => $items]);
}
Expand Down Expand Up @@ -91,7 +91,6 @@ public function testErrorAggregation()

foreach ($aggregatedErrors as $currentError) {
$this->assertEquals('index', $currentError['index']);
$this->assertEquals('type', $currentError['document_type']);
$this->assertEquals('index', $currentError['operation']);
$this->assertEquals(2, $currentError['count']);
$this->assertCount(2, $currentError['document_ids']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ public function testExecuteBulkWithErrors()
$this->clientMock->method('bulk')->will($this->returnValue([
'errors' => true,
'items' => [
['index' => ['_index' => 'index', '_type' => 'type', '_id' => 'doc1']],
['index' => ['_index' => 'index', '_type' => 'type', '_id' => 'doc2']],
['index' => ['_index' => 'index', '_type' => 'type', '_id' => 'doc3', 'error' => $error1]],
['index' => ['_index' => 'index', '_type' => 'type', '_id' => 'doc4', 'error' => $error1]],
['index' => ['_index' => 'index', '_type' => 'type', '_id' => 'doc5', 'error' => $error2]],
['index' => ['_index' => 'index', '_type' => 'type', '_id' => 'doc6', 'error' => $error2]],
['index' => ['_index' => 'index', '_id' => 'doc1']],
['index' => ['_index' => 'index', '_id' => 'doc2']],
['index' => ['_index' => 'index', '_id' => 'doc3', 'error' => $error1]],
['index' => ['_index' => 'index', '_id' => 'doc4', 'error' => $error1]],
['index' => ['_index' => 'index', '_id' => 'doc5', 'error' => $error2]],
['index' => ['_index' => 'index', '_id' => 'doc6', 'error' => $error2]],
],
]));

Expand All @@ -166,7 +166,7 @@ public function testExecuteBulkWithErrors()
$this->assertArrayHasKey('errors', $this->logRows);
$this->assertCount(2, $this->logRows['errors']);
$errMessages = [
'Bulk index operation failed 2 times in index index for type type.',
'Bulk index operation failed 2 times in index index.',
'Error (reason2) : Reason 2.',
'Failed doc ids sample : doc5, doc6.',
];
Expand Down

0 comments on commit f9ecaeb

Please sign in to comment.