diff --git a/lib/commands/command-plugin-test.bash b/lib/commands/command-plugin-test.bash index 07d51827..82f1e2ce 100644 --- a/lib/commands/command-plugin-test.bash +++ b/lib/commands/command-plugin-test.bash @@ -9,24 +9,26 @@ plugin_test_command() { local plugin_gitref="master" local tool_version local interpret_args_literally + local skip_next_arg for arg; do shift - if [ -n "${interpret_args_literally}" ]; then + if [ -n "${skip_next_arg}" ]; then + skip_next_arg= + elif [ -n "${interpret_args_literally}" ]; then set -- "$@" "${arg}" else case "${arg}" in --asdf-plugin-gitref) - plugin_gitref="$2" - shift 2 + plugin_gitref="$1" + skip_next_arg=true ;; --asdf-tool-version) - tool_version="$2" - shift 2 + tool_version="$1" + skip_next_arg=true ;; --) interpret_args_literally=true - shift ;; *) set -- "$@" "${arg}" diff --git a/test/fixtures/dummy_plugin/LICENSE b/test/fixtures/dummy_plugin/LICENSE new file mode 100644 index 00000000..d3084751 --- /dev/null +++ b/test/fixtures/dummy_plugin/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2014 Akash Manohar J + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/test/plugin_test_command.bats b/test/plugin_test_command.bats index 332ce1d9..1b486649 100644 --- a/test/plugin_test_command.bats +++ b/test/plugin_test_command.bats @@ -4,6 +4,7 @@ load test_helpers setup() { setup_asdf_dir + install_mock_plugin_repo "dummy" } teardown() { @@ -21,3 +22,17 @@ teardown() { [ "$status" -eq 1 ] [ "$output" = "FAILED: please provide a plugin name and url" ] } + +@test "plugin_test_command works with no options provided" { + run asdf plugin-test dummy "${BASE_DIR}/repo-dummy" + echo "status = ${status}" + echo "output = ${output}" + [ "$status" -eq 0 ] +} + +@test "plugin_test_command works with all options provided" { + run asdf plugin-test dummy "${BASE_DIR}/repo-dummy" --asdf-tool-version 1.0.0 --asdf-plugin-gitref master + echo "status = ${status}" + echo "output = ${output}" + [ "$status" -eq 0 ] +}