2020-07-31 01:47:18 -07:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helpers
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
setup_asdf_dir
|
|
|
|
install_dummy_plugin
|
|
|
|
install_dummy_legacy_plugin
|
|
|
|
run asdf install dummy 1.0
|
|
|
|
run asdf install dummy 1.1
|
|
|
|
|
2023-01-22 16:36:47 -07:00
|
|
|
PROJECT_DIR="$HOME/project"
|
|
|
|
mkdir -p "$PROJECT_DIR"
|
2020-07-31 01:47:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
clean_asdf_dir
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "help should show dummy plugin help" {
|
2023-01-22 21:29:18 -07:00
|
|
|
cd "$PROJECT_DIR"
|
2020-07-31 01:47:18 -07:00
|
|
|
|
|
|
|
run asdf help "dummy"
|
|
|
|
|
2022-06-24 02:20:27 -07:00
|
|
|
expected_output="$(
|
|
|
|
cat <<EOF
|
2020-07-31 01:47:18 -07:00
|
|
|
Dummy plugin documentation
|
|
|
|
|
|
|
|
Dummy plugin is a plugin only used for unit tests
|
|
|
|
EOF
|
2022-06-24 02:20:27 -07:00
|
|
|
)"
|
2020-07-31 01:47:18 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "$expected_output" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "help should show dummy plugin help specific to version when version is present" {
|
2023-01-22 21:29:18 -07:00
|
|
|
cd "$PROJECT_DIR"
|
2020-07-31 01:47:18 -07:00
|
|
|
|
|
|
|
run asdf help "dummy" "1.2.3"
|
|
|
|
|
2022-06-24 02:20:27 -07:00
|
|
|
expected_output="$(
|
|
|
|
cat <<EOF
|
2020-07-31 01:47:18 -07:00
|
|
|
Dummy plugin documentation
|
|
|
|
|
|
|
|
Dummy plugin is a plugin only used for unit tests
|
|
|
|
|
|
|
|
Details specific for version 1.2.3
|
|
|
|
EOF
|
2022-06-24 02:20:27 -07:00
|
|
|
)"
|
2020-07-31 01:47:18 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "$expected_output" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "help should fail for unknown plugins" {
|
2023-01-22 21:29:18 -07:00
|
|
|
cd "$PROJECT_DIR"
|
2020-07-31 01:47:18 -07:00
|
|
|
|
|
|
|
run asdf help "sunny"
|
|
|
|
[ "$status" -eq 1 ]
|
2023-01-14 06:18:44 -07:00
|
|
|
[ "$output" = "No plugin named sunny" ]
|
2020-07-31 01:47:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "help should fail when plugin doesn't have documentation callback" {
|
2023-01-22 21:29:18 -07:00
|
|
|
cd "$PROJECT_DIR"
|
2020-07-31 01:47:18 -07:00
|
|
|
|
|
|
|
run asdf help "legacy-dummy"
|
|
|
|
[ "$status" -eq 1 ]
|
2023-01-14 06:18:44 -07:00
|
|
|
[ "$output" = "No documentation for plugin legacy-dummy" ]
|
2020-07-31 01:47:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "help should show asdf help when no plugin name is provided" {
|
2023-01-22 21:29:18 -07:00
|
|
|
cd "$PROJECT_DIR"
|
2020-07-31 01:47:18 -07:00
|
|
|
|
|
|
|
run asdf help
|
|
|
|
|
|
|
|
[ "$status" -eq 0 ]
|
2023-02-19 04:10:05 -07:00
|
|
|
[[ $output == 'version: v'* ]]
|
|
|
|
[[ $output == *$'MANAGE PLUGINS\n'* ]]
|
|
|
|
[[ $output == *$'MANAGE PACKAGES\n'* ]]
|
|
|
|
[[ $output == *$'UTILS\n'* ]]
|
|
|
|
[[ $output == *$'"Late but latest"\n-- Rajinikanth' ]]
|
2020-07-31 01:47:18 -07:00
|
|
|
}
|