Skip to content

Commit e074aa9

Browse files
Merge #189
189: Fix meili:create when the configuration has no settings r=brunoocasali a=brunoocasali Fixes #176 Co-authored-by: Bruno Casali <[email protected]>
2 parents 3c13cbc + 6eb67c4 commit e074aa9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Command/MeiliSearchCreateCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7272

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

75+
$task = $this->searchClient->createIndex($index['name']);
76+
$this->searchClient->waitForTask($task['uid']);
7577
$indexInstance = $this->searchClient->index($index['name']);
7678

7779
if (isset($index['settings']) && is_array($index['settings'])) {
@@ -83,8 +85,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8385
}
8486

8587
$task = $indexInstance->{$method}($value);
86-
87-
$indexInstance->waitForTask($task['uid']);
8888
$task = $indexInstance->getTask($task['uid']);
8989

9090
if ('failed' === $task['status']) {

tests/Integration/CommandsTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,13 @@ public function testSearchCreateWithIndices(): void
320320

321321
EOD, $createOutput);
322322
}
323+
324+
public function testCreateExecuteIndexCreation(): void
325+
{
326+
$createCommand = $this->application->find('meili:create');
327+
$createCommandTester = new CommandTester($createCommand);
328+
$createCommandTester->execute([]);
329+
330+
$this->assertEquals($this->client->getTasks()['results'][0]['type'], 'indexCreation');
331+
}
323332
}

0 commit comments

Comments
 (0)