List even if there aren't a used version in the version file

main
William Beuil 2021-03-08 12:08:53 +01:00
parent cacd45eb62
commit 9aab0ed515
No known key found for this signature in database
GPG Key ID: BED2072C5C2BF537
2 changed files with 20 additions and 5 deletions

View File

@ -7,12 +7,10 @@ set -uo pipefail
|| log_error "dctlenv versions directory is inaccessible: $DCTLENV_ROOT/versions" || log_error "dctlenv versions directory is inaccessible: $DCTLENV_ROOT/versions"
version_file="$(dctlenv-version-file)" \ version_file="$(dctlenv-version-file)" \
&& log_debug "dctlenv-version-file reported: $version_file" \ && log_debug "dctlenv-version-file reported: $version_file"
|| log_error "dctlenv-version-file failed"
version_name="$(dctlenv-version-name)" \ version_name="$(dctlenv-version-name 2>/dev/null)" \
&& log_debug "dctlenv-version-name reported: $version_name" \ && log_debug "dctlenv-version-name reported: $version_name"
|| log_error "dctlenv-version-name failed"
log_debug 'Listing versions...' log_debug 'Listing versions...'
local_versions=($(\find "$DCTLENV_ROOT/versions" -type d -exec basename {} \; \ local_versions=($(\find "$DCTLENV_ROOT/versions" -type d -exec basename {} \; \

View File

@ -33,6 +33,23 @@ setup() {
OUT 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 <<OUT
0.3.1
0.3.0
0.2.3
OUT
}
teardown() { teardown() {
rm -rf "$DCTLENV_TMPDIR" rm -rf "$DCTLENV_TMPDIR"
} }