diff --git a/plugins/plugin/subcommands/install b/plugins/plugin/subcommands/install index c9cf82926..6516a05f2 100755 --- a/plugins/plugin/subcommands/install +++ b/plugins/plugin/subcommands/install @@ -13,7 +13,7 @@ plugin_install_cmd() { [[ "$#" -gt 2 ]] && dokku_log_info1_quiet "Cannot install additional core plugins, running core plugin install trigger" PLUGIN_PATH="$PLUGIN_CORE_PATH" plugn trigger install ;; - https:* | git* | ssh:* | *.tar.gz | *.tgz) + https:* | git* | ssh:* | file:* | *.tar.gz | *.tgz) shift download_and_enable_plugin "$@" plugn trigger install diff --git a/tests/unit/40_plugin.bats b/tests/unit/40_plugin.bats index 7f2e0e0e5..a2f94b51a 100644 --- a/tests/unit/40_plugin.bats +++ b/tests/unit/40_plugin.bats @@ -3,13 +3,20 @@ load test_helper TEST_PLUGIN_NAME=smoke-test-plugin TEST_PLUGIN_GIT_REPO=https://github.com/dokku/${TEST_PLUGIN_NAME}.git +TEST_PLUGIN_LOCAL_REPO="$(mktemp -d)/$TEST_PLUGIN_NAME" + +clone_test_plugin() { + git clone "$TEST_PLUGIN_GIT_REPO" "$TEST_PLUGIN_LOCAL_REPO" +} setup() { global_setup + clone_test_plugin } remove_test_plugin() { rm -rf $PLUGIN_ENABLED_PATH/$TEST_PLUGIN_NAME $PLUGIN_AVAILABLE_PATH/$TEST_PLUGIN_NAME + rm -rf $TEST_PLUGIN_LOCAL_REPO } teardown() { @@ -59,6 +66,48 @@ teardown() { assert_failure } +@test "(plugin) plugin:install, plugin:disable, plugin:update plugin:uninstall (with file://)" { + run /bin/bash -c "dokku plugin:install file://$TEST_PLUGIN_LOCAL_REPO --name $TEST_PLUGIN_NAME" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku plugin:update $TEST_PLUGIN_NAME" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku plugin | grep enabled | grep $TEST_PLUGIN_NAME" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "sudo -E -u nobody dokku plugin:uninstall $TEST_PLUGIN_NAME" + echo "output: $output" + echo "status: $status" + assert_failure + + run /bin/bash -c "dokku plugin:disable $TEST_PLUGIN_NAME" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku plugin | grep disabled | grep $TEST_PLUGIN_NAME" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku plugin:uninstall $TEST_PLUGIN_NAME" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku plugin | grep $TEST_PLUGIN_NAME" + echo "output: $output" + echo "status: $status" + assert_failure +} + @test "(plugin) plugin:install plugin:update (with tag)" { run /bin/bash -c "dokku plugin:install $TEST_PLUGIN_GIT_REPO --committish v0.2.0 --name $TEST_PLUGIN_NAME" echo "output: $output"