Skip to content

Commit

Permalink
Revert test_uninstall, modify sed command
Browse files Browse the repository at this point in the history
  • Loading branch information
iamhsa committed Oct 7, 2017
1 parent 42cd01f commit f65f3ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libexec/tfenv-uninstall
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ else
fi

[ -n "${version}" ] || error_and_die "Version is not specified"
version="$(tfenv-list | sed 's/ //g;s/^*//;s/(.*)//' | grep -e "${regex}" | head -n 1)"
version="$(tfenv-list | sed -E 's/^(\*| )? //g; s/ \(set by .+\)$//' | grep -e "${regex}" | head -n 1)"
[ -n "${version}" ] || error_and_die "No versions matching '${1}' found in local"

dst_path="${TFENV_ROOT}/versions/${version}"
Expand Down
12 changes: 6 additions & 6 deletions test/test_list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ for v in 0.7.2 0.7.13 0.9.1 0.9.2 0.9.11; do
tfenv install ${v} || error_and_proceed "Install of version ${v} failed"
done

result=$(tfenv list | sed 's/ //g;s/^*//;s/(.*)//')
result=$(tfenv list)
expected="$(cat << EOS
0.9.11
0.9.2
0.9.1
0.7.13
0.7.2
* 0.9.11 (set by $(tfenv version-file))
0.9.2
0.9.1
0.7.13
0.7.2
EOS
)"

Expand Down
5 changes: 4 additions & 1 deletion test/test_uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ v=0.9.1
(
tfenv install ${v} || exit 1
tfenv uninstall ${v} || exit 1
) || error_and_proceed "Uninstalling of version ${v} failed"
check_version ${v} && exit 1 || exit 0
) || error_and_proceed "Uninstall of version ${v} failed"

echo "### Uninstall latest version"
cleanup || error_and_die "Cleanup failed?!"
Expand All @@ -32,6 +33,7 @@ v=$(tfenv list-remote | head -n 1)
(
tfenv install latest || exit 1
tfenv uninstall latest || exit 1
check_version ${v} && exit 1 || exit 0
) || error_and_proceed "Uninstalling latest version ${v}"

echo "### Uninstall latest version with Regex"
Expand All @@ -41,6 +43,7 @@ v=$(tfenv list-remote | grep 0.8 | head -n 1)
(
tfenv install latest:^0.8 || exit 1
tfenv uninstall latest:^0.8 || exit 1
check_version ${v} && exit 1 || exit 0
) || error_and_proceed "Uninstalling latest version ${v} with Regex"

if [ ${#errors[@]} -gt 0 ]; then
Expand Down

0 comments on commit f65f3ac

Please sign in to comment.