fix(taskprocessing): fix TaskProcessingTest

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
pull/54196/head
Julien Veyssier 2025-08-01 13:14:10 +07:00
parent 282bedcfb0
commit f22f7311de
No known key found for this signature in database
GPG Key ID: 4141FEE162030638
1 changed files with 9 additions and 6 deletions

@ -24,6 +24,7 @@ use OCP\Files\Config\IUserMountCache;
use OCP\Files\File;
use OCP\Files\IRootFolder;
use OCP\Http\Client\IClientService;
use OCP\IAppConfig;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IDBConnection;
@ -535,6 +536,7 @@ class TaskProcessingTest extends \Test\TestCase {
private IUserMountCache $userMountCache;
private IRootFolder $rootFolder;
private IConfig $config;
private IAppConfig $appConfig;
public const TEST_USER = 'testuser';
@ -600,8 +602,9 @@ class TaskProcessingTest extends \Test\TestCase {
$this->userMountCache = $this->createMock(IUserMountCache::class);
$this->config = Server::get(IConfig::class);
$this->appConfig = Server::get(IAppConfig::class);
$this->manager = new Manager(
$this->config,
$this->appConfig,
$this->coordinator,
$this->serverContainer,
Server::get(LoggerInterface::class),
@ -641,7 +644,7 @@ class TaskProcessingTest extends \Test\TestCase {
$taskProcessingTypeSettings = [
TextToText::ID => false,
];
$this->config->setAppValue('core', 'ai.taskprocessing_type_preferences', json_encode($taskProcessingTypeSettings));
$this->appConfig->setValueString('core', 'ai.taskprocessing_type_preferences', json_encode($taskProcessingTypeSettings), lazy: true);
self::assertCount(0, $this->manager->getAvailableTaskTypes());
self::assertCount(1, $this->manager->getAvailableTaskTypes(true));
self::assertTrue($this->manager->hasProviders());
@ -651,7 +654,7 @@ class TaskProcessingTest extends \Test\TestCase {
public function testProviderShouldBeRegisteredAndTaskFailValidation(): void {
$this->config->setAppValue('core', 'ai.taskprocessing_type_preferences', '');
$this->appConfig->setValueString('core', 'ai.taskprocessing_type_preferences', '', lazy: true);
$this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
new ServiceRegistration('test', BrokenSyncProvider::class)
]);
@ -797,7 +800,7 @@ class TaskProcessingTest extends \Test\TestCase {
$taskProcessingTypeSettings = [
TextToText::ID => true,
];
$this->config->setAppValue('core', 'ai.taskprocessing_type_preferences', json_encode($taskProcessingTypeSettings));
$this->appConfig->setValueString('core', 'ai.taskprocessing_type_preferences', json_encode($taskProcessingTypeSettings), lazy: true);
self::assertCount(1, $this->manager->getAvailableTaskTypes());
@ -1239,7 +1242,7 @@ class TaskProcessingTest extends \Test\TestCase {
private function createManagerInstance(): Manager {
// Clear potentially cached config values if needed
$this->config->deleteAppValue('core', 'ai.taskprocessing_type_preferences');
$this->appConfig->deleteKey('core', 'ai.taskprocessing_type_preferences');
// Re-create Text2ImageManager if its state matters or mocks change
$text2imageManager = new \OC\TextToImage\Manager(
@ -1253,7 +1256,7 @@ class TaskProcessingTest extends \Test\TestCase {
);
return new Manager(
$this->config,
$this->appConfig,
$this->coordinator,
$this->serverContainer,
Server::get(LoggerInterface::class),