Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ to allow an insecure connection through the mitm proxy.

`beplus` versions added to proxy cache (and used in tests):

* v0.22.0
* v2.0.0
* latest

## Docker Tips
Expand Down
6 changes: 3 additions & 3 deletions test/tests/install-contents.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function setup() {


@test "install: contents" {
readonly TARGET_VERSION="0.22.0"
readonly TARGET_VERSION="2.0.0"
setup_tmp_prefix

[ ! -d "${BE_PREFIX}/be/versions" ]
Expand All @@ -23,7 +23,7 @@ function setup() {
# beplus
[ -f "${BE_PREFIX}/bin/beplus" ]

output="$(beplus --version)"
output="$(beplus --version | cli_version)"
assert_equal "${output}" "${TARGET_VERSION}"

rm -rf "${TMP_PREFIX_DIR}"
Expand All @@ -32,7 +32,7 @@ function setup() {

@test "install: cache prefix" {
readonly BE_CACHE_PREFIX="$(mktemp -d)"
readonly TARGET_VERSION="0.22.0"
readonly TARGET_VERSION="2.0.0"
setup_tmp_prefix
export BE_CACHE_PREFIX

Expand Down
20 changes: 10 additions & 10 deletions test/tests/install-options.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ function teardown() {
}


@test "be --download 0.22.0" {
be --download 0.22.0
[ -d "${BE_PREFIX}/be/versions/beplus/0.22.0" ]
@test "be --download 2.0.0" {
be --download 2.0.0
[ -d "${BE_PREFIX}/be/versions/beplus/2.0.0" ]
[ ! -f "${BE_PREFIX}/bin/beplus" ]
}


@test "be --quiet 0.22.0" {
@test "be --quiet 2.0.0" {
# just checking option is allowed, not testing functionality
be --quiet 0.22.0
output="$(beplus --version)"
assert_equal "${output}" "0.22.0"
be --quiet 2.0.0
output="$(beplus --version | cli_version)"
assert_equal "${output}" "2.0.0"
}


# variations with i/install and latest/numeric
@test "version variations # (2 installs)" {
local VERSION="0.22.0"
local VERSION="2.0.0"
local LATEST_VERSION="$(display_remote_version latest)"

be v${VERSION}
output="$("${BE_PREFIX}/bin/beplus" --version)"
output="$("${BE_PREFIX}/bin/beplus" --version | cli_version)"
assert_equal "${output}" "${VERSION}"

be "${LATEST_VERSION}"
output="$("${BE_PREFIX}/bin/beplus" --version)"
output="$("${BE_PREFIX}/bin/beplus" --version | cli_version)"
assert_equal "${output}" "${LATEST_VERSION}"
}
6 changes: 3 additions & 3 deletions test/tests/install-reference-versions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Run commands we want to cache downloads for.

# Get index into cache for lookups of expected versions. Uncompressed.
curl --location --fail https://api.github.com/repos/beplus/cli/releases &> /dev/null
curl --location --fail https://beplus.s3.amazonaws.com/cli/releases.json &> /dev/null

# Using 0.22.0 as a well known old version (which is no longer getting updated so does not change)
sudo be --download 0.22.0
# Using 2.0.0 as a well known old version (a past release, so it does not change)
sudo be --download 2.0.0
sudo be --download latest
10 changes: 5 additions & 5 deletions test/tests/install-versions.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ function teardown() {

# Testing version permutations in lsr tests

@test "be 0.22.0" {
be 0.22.0
output="$(beplus --version)"
assert_equal "${output}" "0.22.0"
@test "be 2.0.0" {
be 2.0.0
output="$(beplus --version | cli_version)"
assert_equal "${output}" "2.0.0"
}


@test "be latest" {
be latest
output="$(beplus --version)"
output="$(beplus --version | cli_version)"
assert_equal "${output}" "$(display_remote_version latest)"
}
52 changes: 26 additions & 26 deletions test/tests/run-which.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function setup_file() {
# fixed directory so can reuse the two installs
tmpdir="${TMPDIR:-/tmp}"
export BE_PREFIX="${tmpdir}/be/test/run-which"
be --download 0.22.0
be --download 2.0.0
be --download latest
# using "latest" for download tests with run and exec
}
Expand All @@ -20,26 +20,26 @@ function teardown_file() {

@test "setupAll for run/which/exec # (2 installs)" {
# Dummy test so setupAll displayed while running first setup
[ -d "${BE_PREFIX}/be/versions/beplus/0.22.0" ]
[ -d "${BE_PREFIX}/be/versions/beplus/2.0.0" ]
}


# be which

@test "be which 0.22.0" {
output="$(be which 0.22.0)"
assert_equal "$output" "${BE_PREFIX}/be/versions/beplus/0.22.0/beplus"
@test "be which 2.0.0" {
output="$(be which 2.0.0)"
assert_equal "$output" "${BE_PREFIX}/be/versions/beplus/2.0.0/beplus"
}


@test "be which v0.22.0" {
output="$(be which v0.22.0)"
assert_equal "$output" "${BE_PREFIX}/be/versions/beplus/0.22.0/beplus"
@test "be which v2.0.0" {
output="$(be which v2.0.0)"
assert_equal "$output" "${BE_PREFIX}/be/versions/beplus/2.0.0/beplus"
}

@test "be bin v0.22.0" {
output="$(be bin v0.22.0)"
assert_equal "$output" "${BE_PREFIX}/be/versions/beplus/0.22.0/beplus"
@test "be bin v2.0.0" {
output="$(be bin v2.0.0)"
assert_equal "$output" "${BE_PREFIX}/be/versions/beplus/2.0.0/beplus"
}

@test "be which latest" {
Expand All @@ -51,45 +51,45 @@ function teardown_file() {

# be run

@test "be run 0.22.0" {
output="$(be run 0.22.0 --version)"
assert_equal "$output" "0.22.0"
@test "be run 2.0.0" {
output="$(be run 2.0.0 --version | cli_version)"
assert_equal "$output" "2.0.0"
}

@test "be run latest" {
output="$(be run latest --version)"
output="$(be run latest --version | cli_version)"
local LATEST_VERSION="$(display_remote_version latest)"
assert_equal "$output" "${LATEST_VERSION}"
}

@test "be use 0.22.0" {
output="$(be use 0.22.0 --version)"
assert_equal "$output" "0.22.0"
@test "be use 2.0.0" {
output="$(be use 2.0.0 --version | cli_version)"
assert_equal "$output" "2.0.0"
}

@test "be as v0.22.0" {
output="$(be as 0.22.0 --version)"
assert_equal "$output" "0.22.0"
@test "be as v2.0.0" {
output="$(be as 2.0.0 --version | cli_version)"
assert_equal "$output" "2.0.0"
}

@test "be run --download latest" {
be rm latest || true
be run --download latest --version
output="$(be run latest --version)"
output="$(be run latest --version | cli_version)"
local LATEST_VERSION="$(display_remote_version latest)"
assert_equal "$output" "${LATEST_VERSION}"
}


# be exec

@test "be exec v0.22.0 beplus" {
output="$(be exec v0.22.0 beplus --version)"
assert_equal "$output" "0.22.0"
@test "be exec v2.0.0 beplus" {
output="$(be exec v2.0.0 beplus --version | cli_version)"
assert_equal "$output" "2.0.0"
}

@test "be exec latest" {
output="$(be exec latest beplus --version)"
output="$(be exec latest beplus --version | cli_version)"
local LATEST_VERSION="$(display_remote_version latest)"
assert_equal "$output" "${LATEST_VERSION}"
}
14 changes: 13 additions & 1 deletion test/tests/shared-functions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ function setup_tmp_prefix() {
export PATH="${BE_PREFIX}/bin:${PATH}"
}

#
# Synopsis: beplus --version | cli_version
# The version a beplus binary reports, without the leading v. 2.x prints a banner whose first
# line is "beplus CLI vX.Y.Z", where older builds printed just the version.
#

function cli_version() {
sed -n -E 's/^[[:space:]]*(beplus CLI )?v?([0-9]+\.[0-9]+\.[0-9]+[^[:space:]]*)[[:space:]]*$/\2/p' | head -n 1
}

#
# @todo Duplicate
# Synopsis: is_numeric_version version
Expand Down Expand Up @@ -106,7 +116,9 @@ function display_remote_version() {
abort "invalid version '$1'"
fi

local index_url="https://api.github.com/repos/beplus/cli/releases"
# The same index be reads: the GitHub Releases API lists builds the mirror does not host, and
# rate-limits unauthenticated callers such as CI runners.
local index_url="${BE_RELEASE_INDEX_URL:-https://beplus.s3.amazonaws.com/cli/releases.json}"

local jq_release_filter='.[]'
if [[ -n "${official_only}" ]]; then
Expand Down
6 changes: 3 additions & 3 deletions test/tests/uninstall.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ function teardown() {
}


@test "be uninstall (of 0.22.0)" {
be 0.22.0
@test "be uninstall (of 2.0.0)" {
be 2.0.0
[ -f "${BE_PREFIX}/bin/beplus" ]

# Check we get all the files if we uninstall and rm cache.
echo y | be uninstall
be rm 0.22.0
be rm 2.0.0
output="$(find "${BE_PREFIX}" -not -type d)"
assert_equal "$output" ""
}
Expand Down