From 2feb67d0f7749b584f9a9c6fb3aaa4617946afd6 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Fri, 3 May 2024 09:28:02 -0700 Subject: [PATCH] fix tests --- dev/src/Command/AddComponentCommand.php | 2 +- dev/src/Component.php | 6 +++--- dev/tests/Unit/Command/AddComponentCommandTest.php | 2 +- dev/tests/Unit/Command/ComponentInfoCommandTest.php | 13 ------------- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/dev/src/Command/AddComponentCommand.php b/dev/src/Command/AddComponentCommand.php index b7cc196a0946..f559046ae62f 100644 --- a/dev/src/Command/AddComponentCommand.php +++ b/dev/src/Command/AddComponentCommand.php @@ -200,7 +200,7 @@ protected function execute(InputInterface $input, OutputInterface $output) ]; $repoMetadataFullPath = $this->rootPath . '/.repo-metadata-full.json'; $repoMetadataFull = json_decode(file_get_contents($repoMetadataFullPath), true); - $repoMetadataFull[$new->composerPackage] = $repoMetadata; + $repoMetadataFull[$new->componentName] = $repoMetadata; file_put_contents( $repoMetadataFullPath, json_encode($repoMetadataFull, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) diff --git a/dev/src/Component.php b/dev/src/Component.php index f2adb8c743d6..742336d28de3 100644 --- a/dev/src/Component.php +++ b/dev/src/Component.php @@ -187,13 +187,13 @@ private function validateComponentFiles(): void if (!$repoMetadataFullJson) { throw new RuntimeException('Invalid .repo-metadata-full.json'); } - if (!isset($repoMetadataFullJson[$this->packageName])) { + if (!isset($repoMetadataFullJson[$this->name])) { throw new RuntimeException(sprintf( - 'repo metadata not found in .repo-metadata-full.json for component "%s"', + 'repo metadata for component "%s" not found in .repo-metadata-full.json', $this->name )); } - $repoMetadataJson = $repoMetadataFullJson[$this->packageName]; + $repoMetadataJson = $repoMetadataFullJson[$this->name]; if (empty($repoMetadataJson['release_level'])) { throw new RuntimeException(sprintf( 'repo metadata does not contain "release_level" for component "%s"', diff --git a/dev/tests/Unit/Command/AddComponentCommandTest.php b/dev/tests/Unit/Command/AddComponentCommandTest.php index 73e090d0bbb4..ccf47b440ffa 100644 --- a/dev/tests/Unit/Command/AddComponentCommandTest.php +++ b/dev/tests/Unit/Command/AddComponentCommandTest.php @@ -98,7 +98,7 @@ public function testAddComponent() } $repoMetadataFull = json_decode(file_get_contents(self::$tmpDir . '/.repo-metadata-full.json'), true); - $this->assertArrayHasKey('google/cloud-secretmanager', $repoMetadataFull); + $this->assertArrayHasKey('SecretManager', $repoMetadataFull); $this->assertComposerJson('SecretManager'); } diff --git a/dev/tests/Unit/Command/ComponentInfoCommandTest.php b/dev/tests/Unit/Command/ComponentInfoCommandTest.php index f1b83f939304..0165d61a4788 100644 --- a/dev/tests/Unit/Command/ComponentInfoCommandTest.php +++ b/dev/tests/Unit/Command/ComponentInfoCommandTest.php @@ -28,19 +28,6 @@ */ class ComponentInfoCommandTest extends TestCase { - private static $expectedFiles = [ - '.OwlBot.yaml', - '.gitattributes', - '.github/pull_request_template.md', - '.repo-metadata.json', - 'CONTRIBUTING.md', - 'LICENSE', - 'README.md', - 'VERSION', - 'owlbot.py', - 'phpunit.xml.dist', - ]; - private static CommandTester $commandTester; public static function setUpBeforeClass(): void