From 9aab0ed5158d895e7ab9cb7f134574441de39881 Mon Sep 17 00:00:00 2001 From: William Beuil Date: Mon, 8 Mar 2021 12:08:53 +0100 Subject: [PATCH] List even if there aren't a used version in the version file --- libexec/dctlenv-list | 8 +++----- test/dctlenv-list.bats | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) 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 <