diff --git a/libexec/dctlenv-list b/libexec/dctlenv-list index 24d77ce..3b2598b 100755 --- a/libexec/dctlenv-list +++ b/libexec/dctlenv-list @@ -7,12 +7,10 @@ set -uo pipefail || log_error "dctlenv versions directory is inaccessible: $DCTLENV_ROOT/versions" version_file="$(dctlenv-version-file)" \ - && log_debug "dctlenv-version-file reported: $version_file" \ - || log_error "dctlenv-version-file failed" + && log_debug "dctlenv-version-file reported: $version_file" -version_name="$(dctlenv-version-name)" \ - && log_debug "dctlenv-version-name reported: $version_name" \ - || log_error "dctlenv-version-name failed" +version_name="$(dctlenv-version-name 2>/dev/null)" \ + && log_debug "dctlenv-version-name reported: $version_name" log_debug 'Listing versions...' local_versions=($(\find "$DCTLENV_ROOT/versions" -type d -exec basename {} \; \ diff --git a/test/dctlenv-list.bats b/test/dctlenv-list.bats index 60cd766..f819906 100644 --- a/test/dctlenv-list.bats +++ b/test/dctlenv-list.bats @@ -33,6 +33,23 @@ setup() { OUT } +@test "dctlenv list: prints all installed versions without a used version" { + curlw() { echo "$(cat ./test/mocks/list-remote.json)"; }; export -f curlw; + + mkdir -p "$DCTLENV_TMPDIR/versions/0.3.1" + mkdir -p "$DCTLENV_TMPDIR/versions/0.3.0" + mkdir -p "$DCTLENV_TMPDIR/versions/0.2.3" + + run dctlenv list + + assert_success + assert_output <