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 1cfff89 commit d52ab31
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions tests/lib/TaskProcessing/TaskProcessingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ protected function setUp(): void {
$taskProcessingTypeSettings = [];
$taskProcessingTypeSettings[TextToText::ID] = false;

fwrite(STDERR, print_r($taskProcessingTypeSettings, TRUE));

$disabledConfig = $this->createMock(IConfig::class);
$disabledConfig
->method('getAppValue')
Expand Down Expand Up @@ -524,9 +526,11 @@ public function testProviderShouldBeRegisteredAndTaskTypeDisabled(): void {
$this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
new ServiceRegistration('test', SuccessfulSyncProvider::class)
]);
$output = $this->disabledTypeManager->getAvailableTaskTypes(true);
fwrite(STDERR, print_r($output, TRUE));
self::assertCount(0, $this->disabledTypeManager->getAvailableTaskTypes());
self::assertCount(1, $this->disabledTypeManager->getAvailableTaskTypes(true));
self::assertFalse($this->disabledTypeManager->hasProviders());
// self::assertFalse($this->disabledTypeManager->hasProviders());
self::expectException(\OCP\TaskProcessing\Exception\PreConditionNotMetException::class);
$this->disabledTypeManager->scheduleTask(new Task(TextToText::ID, ['input' => 'Hello'], 'test', null));
}
Expand All @@ -536,23 +540,15 @@ public function testProviderShouldBeRegisteredAndTaskTypeDisabled2(): void {
$this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
new ServiceRegistration('test', SuccessfulSyncProvider::class)
]);
$output = $this->disabledTypeManager->getAvailableTaskTypes(true);
fwrite(STDERR, print_r($output, TRUE));
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([
Expand Down

0 comments on commit d52ab31

Please sign in to comment.