You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 line
2.3 KiB

  1. #!/usr/bin/env bats
  2. load test_helper
  3. export PYTHON_BUILD_SKIP_MIRROR=1
  4. export PYTHON_BUILD_CACHE_PATH="$TMP/cache"
  5. setup() {
  6. mkdir "$PYTHON_BUILD_CACHE_PATH"
  7. }
  8. @test "packages are saved to download cache" {
  9. stub shasum true
  10. stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
  11. install_fixture definitions/without-checksum
  12. [ "$status" -eq 0 ]
  13. [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
  14. unstub curl
  15. unstub shasum
  16. }
  17. @test "cached package without checksum" {
  18. stub shasum true
  19. stub curl
  20. cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_CACHE_PATH"
  21. install_fixture definitions/without-checksum
  22. [ "$status" -eq 0 ]
  23. [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
  24. unstub curl
  25. unstub shasum
  26. }
  27. @test "cached package with valid checksum" {
  28. stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
  29. stub curl
  30. cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_CACHE_PATH"
  31. install_fixture definitions/with-checksum
  32. [ "$status" -eq 0 ]
  33. [ -x "${INSTALL_ROOT}/bin/package" ]
  34. [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
  35. unstub curl
  36. unstub shasum
  37. }
  38. @test "cached package with invalid checksum falls back to mirror and updates cache" {
  39. export PYTHON_BUILD_SKIP_MIRROR=
  40. local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
  41. stub shasum true "echo invalid" "echo $checksum"
  42. stub curl "-*I* : true" \
  43. "-q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3"
  44. touch "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
  45. install_fixture definitions/with-checksum
  46. [ "$status" -eq 0 ]
  47. [ -x "${INSTALL_ROOT}/bin/package" ]
  48. [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
  49. diff -q "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" "${FIXTURE_ROOT}/package-1.0.0.tar.gz"
  50. unstub curl
  51. unstub shasum
  52. }
  53. @test "nonexistent cache directory is ignored" {
  54. stub shasum true
  55. stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
  56. export PYTHON_BUILD_CACHE_PATH="${TMP}/nonexistent"
  57. install_fixture definitions/without-checksum
  58. [ "$status" -eq 0 ]
  59. [ -x "${INSTALL_ROOT}/bin/package" ]
  60. [ ! -d "$PYTHON_BUILD_CACHE_PATH" ]
  61. unstub curl
  62. unstub shasum
  63. }