From 8703b1d2262bd5f5e3251b96fff02c4ba107ed18 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Wed, 24 Aug 2022 17:07:48 +0200 Subject: [PATCH] Fix the code to allow for pre-releases to not break code base Signed-off-by: Christian Wolf --- .github/actions/deploy/update-data.sh | 2 +- lib/Controller/MainController.php | 2 +- tests/Unit/Controller/MainControllerTest.php | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/actions/deploy/update-data.sh b/.github/actions/deploy/update-data.sh index 7c328691..55d9fec2 100755 --- a/.github/actions/deploy/update-data.sh +++ b/.github/actions/deploy/update-data.sh @@ -34,7 +34,7 @@ git add package.json echo "Updating version in main controller" version_arr="$major, $minor, $patch" if [ -n "$suffix" ]; then - version_arr="$version_arr, -$suffix" + version_arr="$version_arr, '-$suffix'" fi sed "/VERSION_TAG/s@[[].*[]]@[$version_arr]@" -i lib/Controller/MainController.php git add lib/Controller/MainController.php diff --git a/lib/Controller/MainController.php b/lib/Controller/MainController.php index 53228576..89e6cde2 100755 --- a/lib/Controller/MainController.php +++ b/lib/Controller/MainController.php @@ -97,7 +97,7 @@ class MainController extends Controller { */ public function getApiVersion(): DataResponse { $response = [ - 'cookbook_version' => [0, 9, 14, -beta1], /* VERSION_TAG do not change this line manually */ + 'cookbook_version' => [0, 9, 14, '-beta1'], /* VERSION_TAG do not change this line manually */ 'api_version' => [ 'epoch' => 0, 'major' => 0, diff --git a/tests/Unit/Controller/MainControllerTest.php b/tests/Unit/Controller/MainControllerTest.php index 54d210b8..f6552194 100644 --- a/tests/Unit/Controller/MainControllerTest.php +++ b/tests/Unit/Controller/MainControllerTest.php @@ -96,11 +96,16 @@ class MainControllerTest extends TestCase { public function testGetAPIVersion(): void { $ret = $this->sut->getApiVersion(); + $this->assertEquals(200, $ret->getStatus()); $retData = $ret->getData(); $this->assertTrue(isset($retData['cookbook_version'])); - $this->assertEquals(3, count($retData['cookbook_version'])); + $this->assertTrue(count($retData['cookbook_version']) === 3 || count($retData['cookbook_version']) === 4); + $this->assertTrue(is_int($retData['cookbook_version'][0])); + $this->assertTrue(is_int($retData['cookbook_version'][1])); + $this->assertTrue(is_int($retData['cookbook_version'][2])); + $this->assertTrue(isset($retData['api_version'])); $this->assertTrue(isset($retData['api_version']['epoch'])); $this->assertTrue(isset($retData['api_version']['major']));