Skip to content

Commit

Permalink
Fix meili:create when the configuration has no settings
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoocasali committed Jul 5, 2022
1 parent 3c13cbc commit 7cee41f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Command/MeiliSearchCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$output->writeln('<info>Creating index '.$index['name'].' for '.$entityClassName.'</info>');

$indexInstance = $this->searchClient->index($index['name']);
$task = $this->searchClient->createIndex($index['name']);
$this->searchClient->waitForTask($task['uid']);
$indexInstance = $this->searchClient->getIndex($index['name']);

if (isset($index['settings']) && is_array($index['settings'])) {
foreach ($index['settings'] as $variable => $value) {
Expand All @@ -83,8 +85,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$task = $indexInstance->{$method}($value);

$indexInstance->waitForTask($task['uid']);
$task = $indexInstance->getTask($task['uid']);

if ('failed' === $task['status']) {
Expand Down
9 changes: 9 additions & 0 deletions tests/Integration/CommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,13 @@ public function testSearchCreateWithIndices(): void

EOD, $createOutput);
}

public function testCreateExecuteIndexCreation(): void
{
$createCommand = $this->application->find('meili:create');
$createCommandTester = new CommandTester($createCommand);
$createCommandTester->execute([]);

$this->assertEquals($this->client->getTasks()['results'][0]['type'], 'indexCreation');
}
}

0 comments on commit 7cee41f

Please sign in to comment.