diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2023-04-25 12:10:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-25 12:10:43 +0200 |
commit | 7250f54ca32c1c353470fbc4042ee648e57b760f (patch) | |
tree | 15be4b1e070978f81ee9481238e27f5d704e6997 /tests/lib/BackgroundJob/JobListTest.php | |
parent | 77bb867ad5c74216364d593c419419412d27594f (diff) | |
parent | 06d6cf4ebcc49d97f89b46e127599b97f8fa1800 (diff) | |
download | nextcloud-server-7250f54ca32c1c353470fbc4042ee648e57b760f.tar.gz nextcloud-server-7250f54ca32c1c353470fbc4042ee648e57b760f.zip |
Merge pull request #37835 from nextcloud/feat/background-allow-parallel-runs
feat(BackgroundJobs): Allow preventing parallel runs for a job class
Diffstat (limited to 'tests/lib/BackgroundJob/JobListTest.php')
-rw-r--r-- | tests/lib/BackgroundJob/JobListTest.php | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/lib/BackgroundJob/JobListTest.php b/tests/lib/BackgroundJob/JobListTest.php index ea02e1cd8b9..c15e556d5f7 100644 --- a/tests/lib/BackgroundJob/JobListTest.php +++ b/tests/lib/BackgroundJob/JobListTest.php @@ -12,6 +12,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJob; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IConfig; +use Psr\Log\LoggerInterface; use Test\TestCase; /** @@ -32,6 +33,7 @@ class JobListTest extends TestCase { /** @var \OCP\AppFramework\Utility\ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ protected $timeFactory; + private bool $ran = false; protected function setUp(): void { parent::setUp(); @@ -43,7 +45,8 @@ class JobListTest extends TestCase { $this->instance = new \OC\BackgroundJob\JobList( $this->connection, $this->config, - $this->timeFactory + $this->timeFactory, + \OC::$server->get(LoggerInterface::class), ); } @@ -244,4 +247,24 @@ class JobListTest extends TestCase { $this->assertGreaterThanOrEqual($timeStart, $addedJob->getLastRun()); $this->assertLessThanOrEqual($timeEnd, $addedJob->getLastRun()); } + + public function testHasReservedJobs() { + $this->clearJobsList(); + $job = new TestJob($this->timeFactory, $this, function () { + $this->assertTrue($this->instance->hasReservedJob()); + $this->assertTrue($this->instance->hasReservedJob(TestJob::class)); + }); + $this->instance->add($job); + + $this->assertFalse($this->instance->hasReservedJob()); + $this->assertFalse($this->instance->hasReservedJob(TestJob::class)); + + $job->start($this->instance); + + $this->assertTrue($this->ran); + } + + public function markRun() { + $this->ran = true; + } } |