Skip to content

Commit

Permalink
Harden delete-index, Add check
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Erkelens committed Oct 19, 2023
1 parent bcd9725 commit 136e7b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Indexes/ElasticIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function init()
* @throws NotFoundExceptionInterface
* @throws ServerResponseException
*/
public function deleteIndex(?HTTPRequest $request = null): bool
public function deleteIndex(HTTPRequest $request): bool
{
$deleteResult = false;
if ($this->shouldClear($request) && $this->indexExists()) {
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/Tasks/ElasticIndexTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public function testRun()
$request = new HTTPRequest('GET', 'dev/tasks/ElasticIndexTask');
$result = $task->run($request);

$this->assertGreaterThan(0, $result);
$this->assertinstanceOf(ElasticIndex::class, $task->getIndex());
$request = new HTTPRequest('GET', 'dev/tasks/ElasticIndexTask', ['clear' => true]);
$result = $task->run($request);

$this->assertGreaterThan(0, $result);
$this->assertinstanceOf(ElasticIndex::class, $task->getIndex());
}
Expand Down

0 comments on commit 136e7b2

Please sign in to comment.