aboutsummaryrefslogtreecommitdiffstats
path: root/apps/testing/lib/TaskProcessing/FakeTextToImageProvider.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-11-18 22:01:15 +0100
committerJoas Schilling <coding@schilljs.com>2024-11-18 22:01:15 +0100
commit5e5a53c0989875fc425db549b1b940b9349a6295 (patch)
tree30634aedfe2d345b74203cd28d3a3a6c5122dbb9 /apps/testing/lib/TaskProcessing/FakeTextToImageProvider.php
parent8995272f60b7d30c58565aa0eeb01e39f3629644 (diff)
downloadnextcloud-server-5e5a53c0989875fc425db549b1b940b9349a6295.tar.gz
nextcloud-server-5e5a53c0989875fc425db549b1b940b9349a6295.zip
test(fakeAI): Allow to specify whether the fake providers should failbugfix/noid/allow-to-fail-fake-AI-providers
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/testing/lib/TaskProcessing/FakeTextToImageProvider.php')
-rw-r--r--apps/testing/lib/TaskProcessing/FakeTextToImageProvider.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/apps/testing/lib/TaskProcessing/FakeTextToImageProvider.php b/apps/testing/lib/TaskProcessing/FakeTextToImageProvider.php
index 429b3af9d57..cd508be9155 100644
--- a/apps/testing/lib/TaskProcessing/FakeTextToImageProvider.php
+++ b/apps/testing/lib/TaskProcessing/FakeTextToImageProvider.php
@@ -9,7 +9,9 @@ declare(strict_types=1);
namespace OCA\Testing\TaskProcessing;
use OCA\Testing\AppInfo\Application;
+use OCP\AppFramework\Services\IAppConfig;
use OCP\TaskProcessing\EShapeType;
+use OCP\TaskProcessing\Exception\ProcessingException;
use OCP\TaskProcessing\ISynchronousProvider;
use OCP\TaskProcessing\ShapeDescriptor;
use OCP\TaskProcessing\TaskTypes\TextToImage;
@@ -17,7 +19,9 @@ use RuntimeException;
class FakeTextToImageProvider implements ISynchronousProvider {
- public function __construct() {
+ public function __construct(
+ protected IAppConfig $appConfig,
+ ) {
}
public function getId(): string {
@@ -77,6 +81,10 @@ class FakeTextToImageProvider implements ISynchronousProvider {
}
public function process(?string $userId, array $input, callable $reportProgress): array {
+ if ($this->appConfig->getAppValueBool('fail-' . $this->getId())) {
+ throw new ProcessingException('Failing as set by AppConfig');
+ }
+
if (!isset($input['input']) || !is_string($input['input'])) {
throw new RuntimeException('Invalid prompt');
}