Skip to content

Commit

Permalink
Merge pull request #28 from kamatama41/check-version-name
Browse files Browse the repository at this point in the history
Check version name is correct before install
  • Loading branch information
kamatama41 authored Jan 22, 2017
2 parents ed675ae + 012e879 commit 6a8c6b8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libexec/tfenv---version
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
set -e
[ -n "$TFENV_DEBUG" ] && set -x

version="0.3.2"
version="0.3.3"
git_revision=""

if cd "${BASH_SOURCE%/*}" 2>/dev/null && git remote -v 2>/dev/null | grep -q tfenv; then
Expand Down
5 changes: 5 additions & 0 deletions libexec/tfenv-install
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ if [ -f ${dst_path}/terraform ];then
exit
fi

if [ -z "$(tfenv-list-remote | grep "${version}")" ];then
echo "'${version}' doesn't exist in remote, please confirm version name."
exit 1
fi

case "$(uname -s)" in
Darwin* )
os="darwin_amd64"
Expand Down
12 changes: 11 additions & 1 deletion test/test_install_and_use.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi
echo "### Install specific version"
cleanup

v=0.6.16
v=0.7.13
tfenv install ${v}
tfenv use ${v}
if ! check_version ${v}; then
Expand All @@ -35,3 +35,13 @@ if ! check_version ${v}; then
echo "Installing .terraform-version ${v}" 1>&2
exit 1
fi

echo "### Install invalid version"
cleanup

v=9.9.9
expected_error_message="'${v}' doesn't exist in remote, please confirm version name."
if [ -z "$(tfenv install ${v} | grep "${expected_error_message}")" ]; then
echo "Installing invalid version ${v}" 1>&2
exit 1
fi
6 changes: 3 additions & 3 deletions test/test_list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ source $(dirname $0)/helpers.sh
echo "### List local versions"
cleanup

for v in 0.6.2 0.6.16 0.7.0-rc4 0.7.0 0.8.0-beta2; do
for v in 0.6.16 0.7.0-rc4 0.7.2 0.7.13 0.8.0-beta2; do
tfenv install ${v}
done

result=$(tfenv list)
expected="$(cat << EOS
0.8.0-beta2
0.7.0
0.7.13
0.7.2
0.7.0-rc4
0.6.16
0.6.2
EOS
)"
if [ "${expected}" != "${result}" ]; then
Expand Down

0 comments on commit 6a8c6b8

Please sign in to comment.