Commit 275b2f59 authored by Sam Stephenson's avatar Sam Stephenson
Browse files

Test checksumming

parent 86f9cb7d
Loading
Loading
Loading
Loading

test/checksum.bats

0 → 100644
+70 −0
Original line number Diff line number Diff line
#!/usr/bin/env bats

load test_helper
export RUBY_BUILD_SKIP_MIRROR=1
export RUBY_BUILD_CACHE_PATH=


@test "package URL without checksum" {
  stub md5 true
  stub curl "-*S* : cat package-1.0.0.tar.gz"

  install_fixture definitions/without-checksum
  [ "$status" -eq 0 ]
  [ -x "${INSTALL_ROOT}/bin/package" ]

  unstub curl
  unstub md5
}


@test "package URL with valid checksum" {
  stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
  stub curl "-*S* : cat package-1.0.0.tar.gz"

  install_fixture definitions/with-checksum
  [ "$status" -eq 0 ]
  [ -x "${INSTALL_ROOT}/bin/package" ]

  unstub curl
  unstub md5
}


@test "package URL with invalid checksum" {
  stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
  stub curl "-*S* : cat package-1.0.0.tar.gz"

  install_fixture definitions/with-invalid-checksum
  [ "$status" -eq 1 ]
  [ ! -f "${INSTALL_ROOT}/bin/package" ]

  unstub curl
  unstub md5
}


@test "package URL with checksum but no MD5 support" {
  stub md5 false
  stub curl "-*S* : cat package-1.0.0.tar.gz"

  install_fixture definitions/with-checksum
  [ "$status" -eq 0 ]
  [ -x "${INSTALL_ROOT}/bin/package" ]

  unstub curl
  unstub md5
}


@test "package with invalid checksum" {
  stub md5 true "echo invalid"
  stub curl "-*S* : cat package-1.0.0.tar.gz"

  install_fixture definitions/with-checksum
  [ "$status" -eq 1 ]
  [ ! -f "${INSTALL_ROOT}/bin/package" ]

  unstub curl
  unstub md5
}
+1 −0
Original line number Diff line number Diff line
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#83e6d7725e20166024a1eb74cde80677" copy
+1 −0
Original line number Diff line number Diff line
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#invalid" copy
+1 −0
Original line number Diff line number Diff line
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz" copy
+210 B

File added.

No diff preview for this file type.

Loading