Skip to content

Commit

Permalink
test: add disabled task type unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Jana Peper <jana.peper@nextcloud.com>
  • Loading branch information
janepie committed Dec 11, 2024
1 parent 2ef0fc8 commit 1cfff89
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/lib/TaskProcessing/TaskProcessingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,29 @@ public function testProviderShouldBeRegisteredAndTaskTypeDisabled(): void {
$this->disabledTypeManager->scheduleTask(new Task(TextToText::ID, ['input' => 'Hello'], 'test', null));
}


public function testProviderShouldBeRegisteredAndTaskTypeDisabled2(): void {
$this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
new ServiceRegistration('test', SuccessfulSyncProvider::class)
]);
self::assertCount(0, $this->manager->getAvailableTaskTypes());
self::assertCount(1, $this->manager->getAvailableTaskTypes(true));
self::assertFalse($this->manager->hasProviders());
self::expectException(\OCP\TaskProcessing\Exception\PreConditionNotMetException::class);
$this->manager->scheduleTask(new Task(TextToText::ID, ['input' => 'Hello'], 'test', null));
}

public function testProviderShouldBeRegisteredAndTaskTypeDisabled3(): void {
$this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
new ServiceRegistration('test', SuccessfulSyncProvider::class)
]);
self::assertCount(1, $this->manager->getAvailableTaskTypes());
self::assertCount(1, $this->manager->getAvailableTaskTypes(true));
self::assertTrue($this->manager->hasProviders());
// self::expectException(\OCP\TaskProcessing\Exception\PreConditionNotMetException::class);
$this->manager->scheduleTask(new Task(TextToText::ID, ['input' => 'Hello'], 'test', null));
}

public function testProviderShouldBeRegisteredAndTaskFailValidation(): void {
$this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
new ServiceRegistration('test', BrokenSyncProvider::class)
Expand Down

0 comments on commit 1cfff89

Please sign in to comment.