Fix the code to allow for pre-releases to not break code base

Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Christian Wolf 2022-08-24 17:07:48 +02:00
Родитель 635aeea330
Коммит 8703b1d226
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 9FC3120E932F73F1
3 изменённых файлов: 8 добавлений и 3 удалений

2
.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

Просмотреть файл

@ -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,

Просмотреть файл

@ -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']));