From 17f0fc7f4a4ffeaa004227755c9926276904a9be Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Mon, 20 Mar 2023 14:08:52 +0100 Subject: Add a command to check the job status and reset it Signed-off-by: Benjamin Brahmer --- tests/Unit/Service/UpdaterTest.php | 14 +++++++++++++- tests/command/update.bats | 21 +++++++++++++++++++++ tests/test_helper/bats-assert | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/command/update.bats (limited to 'tests') diff --git a/tests/Unit/Service/UpdaterTest.php b/tests/Unit/Service/UpdaterTest.php index b4be0a7cc..3d5ca2252 100644 --- a/tests/Unit/Service/UpdaterTest.php +++ b/tests/Unit/Service/UpdaterTest.php @@ -18,6 +18,8 @@ use OCA\News\Service\FolderServiceV2; use OCA\News\Service\ItemServiceV2; use OCA\News\Service\UpdaterService; use PHPUnit\Framework\TestCase; +use OCP\BackgroundJob\IJobList; +use OCP\BackgroundJob\IJob; class UpdaterTest extends TestCase { @@ -42,6 +44,11 @@ class UpdaterTest extends TestCase */ private $updater; + /** + * @var \PHPUnit\Framework\MockObject\MockObject|IJobList + */ + private $jobList; + protected function setUp(): void { $this->folderService = $this->getMockBuilder(FolderServiceV2::class) @@ -53,10 +60,14 @@ class UpdaterTest extends TestCase $this->itemService = $this->getMockBuilder(ItemServiceV2::class) ->disableOriginalConstructor() ->getMock(); + $this->jobList = $this->getMockBuilder(IJobList::class) + ->disableOriginalConstructor() + ->getMock(); $this->updater = new UpdaterService( $this->folderService, $this->feedService, - $this->itemService + $this->itemService, + $this->jobList ); } @@ -83,4 +94,5 @@ class UpdaterTest extends TestCase ->method('fetchAll'); $this->updater->update(); } + } \ No newline at end of file diff --git a/tests/command/update.bats b/tests/command/update.bats new file mode 100644 index 000000000..d94c1cd28 --- /dev/null +++ b/tests/command/update.bats @@ -0,0 +1,21 @@ +#!/usr/bin/env bats + +# This only works with NC 26 + +load "helpers/settings" +load "../test_helper/bats-support/load" +load "../test_helper/bats-assert/load" + +TESTSUITE="Update" + +@test "[$TESTSUITE] Job status" { + run ./occ news:updater:job + + assert_success +} + +@test "[$TESTSUITE] Job reset" { + run ./occ news:updater:job --reset + + assert_success +} \ No newline at end of file diff --git a/tests/test_helper/bats-assert b/tests/test_helper/bats-assert index 78fa631d1..ffe84ea5d 160000 --- a/tests/test_helper/bats-assert +++ b/tests/test_helper/bats-assert @@ -1 +1 @@ -Subproject commit 78fa631d1370562d2cd4a1390989e706158e7bf0 +Subproject commit ffe84ea5dd43b568851549b3e241db150c12929c -- cgit v1.2.3