From 01ca4c268f6fda903c750bf03f131d4d24b228f1 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Wed, 8 Nov 2023 20:46:48 +0530 Subject: [PATCH] Fix code and add correspondingtest --- src/VCS/Adapter/Git/GitHub.php | 2 +- tests/Detector/DetectorTest.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/VCS/Adapter/Git/GitHub.php b/src/VCS/Adapter/Git/GitHub.php index 7e58238b..a6d25a18 100644 --- a/src/VCS/Adapter/Git/GitHub.php +++ b/src/VCS/Adapter/Git/GitHub.php @@ -187,7 +187,7 @@ public function listRepositoryContents(string $owner, string $repositoryName, st $response = $this->call(self::METHOD_GET, $url, ['Authorization' => "Bearer $this->accessToken"]); - if (!is_array($response['body'])) { + if (($response['headers']['status-code'] == 404)) { return []; } diff --git a/tests/Detector/DetectorTest.php b/tests/Detector/DetectorTest.php index 3174d768..2f0a4c13 100644 --- a/tests/Detector/DetectorTest.php +++ b/tests/Detector/DetectorTest.php @@ -61,6 +61,7 @@ public function setUp(): void public function testLanguageDetection(): void { + // test for SUCCESS $languageMap = [ ['vermakhushboo', 'basic-js-crud', 'node'], ['appwrite', 'appwrite', 'php'], @@ -82,5 +83,11 @@ public function testLanguageDetection(): void $runtime = $this->detect($files, $languages); $this->assertEquals($expectedRuntime, $runtime); } + + // test for FAILURE + $files = $this->github->listRepositoryContents('', ''); + $languages = $this->github->listRepositoryLanguages('', ''); + $runtime = $this->detect($files, $languages); + $this->assertEquals(null, $runtime); } }