2012-11-20 06:45:00 +01:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
export RUBY_BUILD_SKIP_MIRROR=1
|
|
|
|
export RUBY_BUILD_CACHE_PATH="$TMP/cache"
|
|
|
|
|
|
|
|
@test "packages are saved to download cache" {
|
2023-11-07 10:17:54 +01:00
|
|
|
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
|
2012-11-20 06:45:00 +01:00
|
|
|
|
2023-10-17 00:18:14 +02:00
|
|
|
mkdir -p "$RUBY_BUILD_CACHE_PATH"
|
2012-11-20 06:45:00 +01:00
|
|
|
install_fixture definitions/without-checksum
|
2016-01-18 17:42:58 +01:00
|
|
|
|
|
|
|
assert_success
|
2015-10-29 15:36:25 +01:00
|
|
|
assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
2012-11-20 06:45:00 +01:00
|
|
|
|
2016-06-10 07:11:26 +02:00
|
|
|
unstub curl
|
2012-11-20 06:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "cached package without checksum" {
|
2016-06-10 07:11:26 +02:00
|
|
|
stub curl
|
2012-11-20 06:45:00 +01:00
|
|
|
|
2023-10-17 00:18:14 +02:00
|
|
|
mkdir -p "$RUBY_BUILD_CACHE_PATH"
|
2012-11-20 06:45:00 +01:00
|
|
|
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH"
|
|
|
|
|
|
|
|
install_fixture definitions/without-checksum
|
2016-01-18 17:42:58 +01:00
|
|
|
|
|
|
|
assert_success
|
2015-10-29 15:36:25 +01:00
|
|
|
assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
2012-11-20 06:45:00 +01:00
|
|
|
|
2016-06-10 07:11:26 +02:00
|
|
|
unstub curl
|
2012-11-20 06:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "cached package with valid checksum" {
|
2014-04-15 16:45:57 +02:00
|
|
|
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
2016-06-10 07:11:26 +02:00
|
|
|
stub curl
|
2012-11-20 06:45:00 +01:00
|
|
|
|
2023-10-17 00:18:14 +02:00
|
|
|
mkdir -p "$RUBY_BUILD_CACHE_PATH"
|
2012-11-20 06:45:00 +01:00
|
|
|
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH"
|
|
|
|
|
|
|
|
install_fixture definitions/with-checksum
|
2016-01-18 17:42:58 +01:00
|
|
|
|
|
|
|
assert_success
|
2015-10-29 15:36:25 +01:00
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
|
|
|
assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
2012-11-20 06:45:00 +01:00
|
|
|
|
2016-06-10 07:11:26 +02:00
|
|
|
unstub curl
|
2014-04-15 16:45:57 +02:00
|
|
|
unstub shasum
|
2012-11-20 06:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "cached package with invalid checksum falls back to mirror and updates cache" {
|
|
|
|
export RUBY_BUILD_SKIP_MIRROR=
|
2014-04-15 16:45:57 +02:00
|
|
|
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
2012-11-20 06:45:00 +01:00
|
|
|
|
2014-04-15 16:45:57 +02:00
|
|
|
stub shasum true "echo invalid" "echo $checksum"
|
2016-06-10 07:11:26 +02:00
|
|
|
stub curl "-*I* : true" \
|
2023-11-07 10:17:54 +01:00
|
|
|
"-q -fL -o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4"
|
2012-11-20 06:45:00 +01:00
|
|
|
|
2023-10-17 00:18:14 +02:00
|
|
|
mkdir -p "$RUBY_BUILD_CACHE_PATH"
|
2012-11-20 06:45:00 +01:00
|
|
|
touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
|
|
|
|
|
|
|
|
install_fixture definitions/with-checksum
|
2016-01-18 17:42:58 +01:00
|
|
|
|
|
|
|
assert_success
|
2015-10-29 15:36:25 +01:00
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
|
|
|
assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
|
|
|
assert diff -q "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" "${FIXTURE_ROOT}/package-1.0.0.tar.gz"
|
2012-11-20 06:45:00 +01:00
|
|
|
|
2016-06-10 07:11:26 +02:00
|
|
|
unstub curl
|
2014-04-15 16:45:57 +02:00
|
|
|
unstub shasum
|
2012-11-20 06:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "nonexistent cache directory is ignored" {
|
2023-11-07 10:17:54 +01:00
|
|
|
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
|
2012-11-20 06:45:00 +01:00
|
|
|
|
|
|
|
export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent"
|
|
|
|
|
|
|
|
install_fixture definitions/without-checksum
|
2016-01-18 17:42:58 +01:00
|
|
|
|
|
|
|
assert_success
|
2015-10-29 15:36:25 +01:00
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
2015-10-29 15:40:32 +01:00
|
|
|
refute [ -d "$RUBY_BUILD_CACHE_PATH" ]
|
2012-11-20 06:45:00 +01:00
|
|
|
|
2016-06-10 07:11:26 +02:00
|
|
|
unstub curl
|
2012-11-20 06:45:00 +01:00
|
|
|
}
|