Skip to content

Commit

Permalink
Add test to reproduce the misleading message
Browse files Browse the repository at this point in the history
Simulation steps, where dummy/dummyman behave like node/npm

- User install dummy 1.0, with `dummyman` command shimmed
- User install dummy 1.3
- User run `dummyman`

will print incorrect message which suggest to install `dummy 1.3` (has
already installed), or set `dummy 1.0` in tool-versions (is not what
user want).
  • Loading branch information
bootleq committed Oct 20, 2024
1 parent c5116dc commit e00e4ac
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/shim_exec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,36 @@ teardown() {
echo "$output" | grep -q "dummy 1.0" 2>/dev/null
}

@test "issue #928" {
# Install 1.0, with fake "dummyman" command, shimmed for 1.0
run asdf install dummy 1.0
echo "echo Dummy Manager" >"$ASDF_DIR/installs/dummy/1.0/bin/dummyman"
chmod +x "$ASDF_DIR/installs/dummy/1.0/bin/dummyman"
run asdf reshim dummy 1.0

# Install 1.3
run asdf install dummy 1.3

echo "dummy 1.3" >"$PROJECT_DIR/.tool-versions"

# reshim doesn't help
run asdf reshim dummy
run asdf shim-versions dummyman
[ "$status" -eq 0 ]
[ "$output" = "dummy 1.0" ]

run "$ASDF_DIR/shims/dummyman"
[ "$status" -eq 126 ]
echo ">> $output" >&3

# Below is current (misleading) message
echo "$output" | grep -q "No preset version installed for command dummyman" 2>/dev/null
echo "$output" | grep -q "Please install a version by running one of the following:" 2>/dev/null
echo "$output" | grep -q "asdf install dummy 1.3" 2>/dev/null
echo "$output" | grep -q "or add one of the following versions in your config file at $PROJECT_DIR/.tool-versions" 2>/dev/null
echo "$output" | grep -q "dummy 1.0" 2>/dev/null
}

@test "shim exec should execute first plugin that is installed and set" {
run asdf install dummy 2.0.0
run asdf install dummy 3.0
Expand Down

0 comments on commit e00e4ac

Please sign in to comment.