mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 06:08:46 -04:00
test: add explicitly enabled task type unit test
Signed-off-by: Jana Peper <jana.peper@nextcloud.com>
This commit is contained in:
parent
e5f7d0017b
commit
b1d1badcf0
1 changed files with 36 additions and 1 deletions
|
|
@ -499,7 +499,6 @@ class TaskProcessingTest extends \Test\TestCase {
|
|||
TextToText::ID => false,
|
||||
];
|
||||
$this->config->setAppValue('core', 'ai.taskprocessing_type_preferences', json_encode($taskProcessingTypeSettings));
|
||||
$context = $this->coordinator->getRegistrationContext();
|
||||
self::assertCount(0, $this->manager->getAvailableTaskTypes());
|
||||
self::assertCount(1, $this->manager->getAvailableTaskTypes(true));
|
||||
self::assertTrue($this->manager->hasProviders());
|
||||
|
|
@ -647,6 +646,42 @@ class TaskProcessingTest extends \Test\TestCase {
|
|||
self::assertEquals(1, $task->getProgress());
|
||||
}
|
||||
|
||||
public function testTaskTypeExplicitlyEnabled(): void {
|
||||
$this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
|
||||
new ServiceRegistration('test', SuccessfulSyncProvider::class)
|
||||
]);
|
||||
|
||||
$taskProcessingTypeSettings = [
|
||||
TextToText::ID => true,
|
||||
];
|
||||
$this->config->setAppValue('core', 'ai.taskprocessing_type_preferences', json_encode($taskProcessingTypeSettings));
|
||||
|
||||
self::assertCount(1, $this->manager->getAvailableTaskTypes());
|
||||
|
||||
self::assertTrue($this->manager->hasProviders());
|
||||
$task = new Task(TextToText::ID, ['input' => 'Hello'], 'test', null);
|
||||
self::assertNull($task->getId());
|
||||
self::assertEquals(Task::STATUS_UNKNOWN, $task->getStatus());
|
||||
$this->manager->scheduleTask($task);
|
||||
self::assertNotNull($task->getId());
|
||||
self::assertEquals(Task::STATUS_SCHEDULED, $task->getStatus());
|
||||
|
||||
$this->eventDispatcher->expects($this->once())->method('dispatchTyped')->with(new IsInstanceOf(TaskSuccessfulEvent::class));
|
||||
|
||||
$backgroundJob = new \OC\TaskProcessing\SynchronousBackgroundJob(
|
||||
\OCP\Server::get(ITimeFactory::class),
|
||||
$this->manager,
|
||||
$this->jobList,
|
||||
\OCP\Server::get(LoggerInterface::class),
|
||||
);
|
||||
$backgroundJob->start($this->jobList);
|
||||
|
||||
$task = $this->manager->getTask($task->getId());
|
||||
self::assertEquals(Task::STATUS_SUCCESSFUL, $task->getStatus(), 'Status is ' . $task->getStatus() . ' with error message: ' . $task->getErrorMessage());
|
||||
self::assertEquals(['output' => 'Hello'], $task->getOutput());
|
||||
self::assertEquals(1, $task->getProgress());
|
||||
}
|
||||
|
||||
public function testAsyncProviderWithFilesShouldBeRegisteredAndRunReturningRawFileData(): void {
|
||||
$this->registrationContext->expects($this->any())->method('getTaskProcessingTaskTypes')->willReturn([
|
||||
new ServiceRegistration('test', AudioToImage::class)
|
||||
|
|
|
|||
Loading…
Reference in a new issue