Skip to content

Commit

Permalink
feat(MPM-668): Use additional check but not the result from parser (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
bajdzun authored Oct 28, 2022
1 parent be91115 commit 8b591d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/Command/RegisterChangedSchemasCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Jobcloud\SchemaConsole\Command;

use AvroSchema;
use AvroSchemaParseException;
use Jobcloud\Kafka\SchemaRegistryClient\Exception\SubjectNotFoundException;
use Jobcloud\Kafka\SchemaRegistryClient\KafkaSchemaRegistryApiClientInterface;
use Jobcloud\SchemaConsole\Helper\SchemaFileHelper;
Expand Down Expand Up @@ -149,12 +151,13 @@ private function registerFiles(
}

try {
$this->schemaRegistryApi->registerNewSchemaVersion($schemaName, $localSchema);
} catch (\Throwable $e) {
AvroSchema::parse($localSchema);
} catch (AvroSchemaParseException $e) {
$io->writeln(sprintf('Skipping %s for now because %s', $schemaName, $e->getMessage()));
$failed[$schemaName] = $schemaName;
continue;
}
$this->schemaRegistryApi->registerNewSchemaVersion($schemaName, $localSchema);

$succeeded[$schemaName] = [
'name' => $schemaName,
Expand Down
6 changes: 0 additions & 6 deletions tests/Command/RegisterChangedSchemasCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,6 @@ public function testOutputWhenCommandFailsRegisteringASchema(): void
'getLatestSubjectVersion' => '1'
]);

$schemaRegistryApi->expects(self::exactly(10))
->method('registerNewSchemaVersion')
->willThrowException(
new \Exception('Skipping test.schema.1 for now because is not a schema we know about.')
);

$application = new Application();
$application->add(new RegisterChangedSchemasCommand($schemaRegistryApi));
$command = $application->find('kafka-schema-registry:register:changed');
Expand Down

0 comments on commit 8b591d9

Please sign in to comment.