diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-06-22 06:36:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-22 06:36:38 +0200 |
commit | 49f1a256676331b566b0b09f98e254fee9a72829 (patch) | |
tree | b125fe91e0fa075b379267cef6cde1ecdb956a5b | |
parent | 4a19ba885e84799f3bcd36688ba6c5ba6022c2ea (diff) | |
parent | 65e4e904c4d074204fdfb3a5251a9c6edb196978 (diff) |
Merge pull request #12547 from nextcloud/skalidindi53/11578/talkbot-uninstall-throws-instead-of-showing-an-error
Shows an error msg when missing args
-rw-r--r-- | lib/Command/Bot/Uninstall.php | 4 | ||||
-rw-r--r-- | tests/integration/features/chat-1/bots.feature | 21 | ||||
-rwxr-xr-x | tests/integration/run-docker.sh | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/lib/Command/Bot/Uninstall.php b/lib/Command/Bot/Uninstall.php index b666c1e93..607362883 100644 --- a/lib/Command/Bot/Uninstall.php +++ b/lib/Command/Bot/Uninstall.php @@ -50,6 +50,10 @@ class Uninstall extends Base { try { if ($botId === 0) { $url = $input->getOption('url'); + if ($url === null) { + $output->writeln('<error>URL is required when no ID is given</error>'); + return 1; + } $bot = $this->botServerMapper->findByUrl($url); } else { $bot = $this->botServerMapper->findById($botId); diff --git a/tests/integration/features/chat-1/bots.feature b/tests/integration/features/chat-1/bots.feature index 3489a0a95..2d784f321 100644 --- a/tests/integration/features/chat-1/bots.feature +++ b/tests/integration/features/chat-1/bots.feature @@ -336,3 +336,24 @@ Feature: chat/bots When user "participant1" sends message "Message 2" to room "room" with 201 Then user "participant1" edits message "Message 2" in room "room" to "Message 2 - Edit 2" with 202 And user "participant1" deletes message "Message 2 - Edit 2" from room "room" with 202 + + Scenario: Uninstalling the bot with invalid parameters + Given invoking occ with "talk:bot:list" + Then the command was successful + And the command output is empty + + # Test uninstall with no parameters + When invoking occ with "talk:bot:uninstall" + Then the command failed with exit code 1 + And the command output contains the text "URL is required when no ID is given" + + # Test uninstall with invalid ID + When invoking occ with "talk:bot:uninstall 2147483647" + Then the command failed with exit code 1 + And the command output contains the text "Bot not found" + + # Test uninstall with invalid URL + When invoking occ with "talk:bot:uninstall --url=https://example.tld" + Then the command failed with exit code 1 + And the command output contains the text "Bot not found" + diff --git a/tests/integration/run-docker.sh b/tests/integration/run-docker.sh index 723c1e3bd..ed7ce6ab5 100755 --- a/tests/integration/run-docker.sh +++ b/tests/integration/run-docker.sh @@ -201,7 +201,7 @@ cd "$(dirname $0)" # "--image XXX" option can be provided to set the Docker image to use to run # the integration tests (one of the "nextcloudci/phpX.Y:phpX.Y-Z" or # "ghcr.io/nextcloud/continuous-integration-phpX.Y:latest" images). -NEXTCLOUD_LOCAL_IMAGE="ghcr.io/nextcloud/continuous-integration-php8.0:latest" +NEXTCLOUD_LOCAL_IMAGE="ghcr.io/nextcloud/continuous-integration-php8.1:latest" if [ "$1" = "--image" ]; then NEXTCLOUD_LOCAL_IMAGE=$2 |