diff options
author | skalidindi53 <s.teja2004@gmail.com> | 2024-06-19 08:32:29 -0500 |
---|---|---|
committer | skalidindi53 <s.teja2004@gmail.com> | 2024-06-21 10:00:11 -0500 |
commit | 65e4e904c4d074204fdfb3a5251a9c6edb196978 (patch) | |
tree | ba60954f00a0466b1d65baf97912acf7e4234188 | |
parent | 66937d6b0ba12a33861df09da45972a1aefddc07 (diff) |
fix: Shows an error msg when missing args
Signed-off-by: skalidindi53 <s.teja2004@gmail.com>
-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 |