-
Notifications
You must be signed in to change notification settings - Fork 832
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: plugin documentation callback support 🎉 (#757)
- Loading branch information
Showing
5 changed files
with
178 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Dummy plugin documentation" | ||
echo | ||
echo "Dummy plugin is a plugin only used for unit tests" | ||
|
||
if [ -n "$ASDF_INSTALL_VERSION" ]; then | ||
echo | ||
echo "Details specific for version $ASDF_INSTALL_VERSION" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/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 | ||
|
||
PROJECT_DIR=$HOME/project | ||
mkdir $PROJECT_DIR | ||
} | ||
|
||
teardown() { | ||
clean_asdf_dir | ||
} | ||
|
||
@test "help should show dummy plugin help" { | ||
cd $PROJECT_DIR | ||
|
||
run asdf help "dummy" | ||
|
||
expected_output="$(cat <<EOF | ||
Dummy plugin documentation | ||
Dummy plugin is a plugin only used for unit tests | ||
EOF | ||
)" | ||
[ "$status" -eq 0 ] | ||
[ "$output" = "$expected_output" ] | ||
} | ||
|
||
@test "help should show dummy plugin help specific to version when version is present" { | ||
cd $PROJECT_DIR | ||
|
||
run asdf help "dummy" "1.2.3" | ||
|
||
expected_output="$(cat <<EOF | ||
Dummy plugin documentation | ||
Dummy plugin is a plugin only used for unit tests | ||
Details specific for version 1.2.3 | ||
EOF | ||
)" | ||
[ "$status" -eq 0 ] | ||
echo $output | ||
[ "$output" = "$expected_output" ] | ||
} | ||
|
||
@test "help should fail for unknown plugins" { | ||
cd $PROJECT_DIR | ||
|
||
run asdf help "sunny" | ||
[ "$status" -eq 1 ] | ||
[ "$output" == "No plugin named sunny" ] | ||
} | ||
|
||
@test "help should fail when plugin doesn't have documentation callback" { | ||
cd $PROJECT_DIR | ||
|
||
run asdf help "legacy-dummy" | ||
[ "$status" -eq 1 ] | ||
[ "$output" == "No documentation for plugin legacy-dummy" ] | ||
} | ||
|
||
@test "help should show asdf help when no plugin name is provided" { | ||
cd $PROJECT_DIR | ||
|
||
run asdf help | ||
|
||
[ "$status" -eq 0 ] | ||
# TODO: Assert asdf help output is printed | ||
} |