Commit 28dcc3f8 authored by Yamashita Yuu's avatar Yamashita Yuu
Browse files

Add tests for `fetch_git`

parent 01e87675
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -12,3 +12,34 @@ export RUBY_BUILD_CACHE_PATH=
  assert_output_contains "> http://example.com/packages/package-1.0.0.tar.gz"
  assert_output_contains "error: failed to download package-1.0.0.tar.gz"
}

@test "fetching from git repository" {
  stub git "clone --depth 1 --branch master http://example.com/packages/package.git package-dev : mkdir package-dev"

  run_inline_definition <<DEF
install_git "package-dev" "http://example.com/packages/package.git" master copy
DEF
  assert_success
  assert_output <<OUT
Cloning http://example.com/packages/package.git...
Installing package-dev...
Installed package-dev to ${TMP}/install
OUT
  unstub git
}

@test "updating existing git repository" {
  stub git "fetch --force --update-head-ok http://example.com/packages/package.git +master:master : true"

  run_inline_definition <<DEF
mkdir "\${BUILD_PATH}/package-dev"
install_git "package-dev" "http://example.com/packages/package.git" master copy
DEF
  assert_success
  assert_output <<OUT
Cloning http://example.com/packages/package.git...
Installing package-dev...
Installed package-dev to ${TMP}/install
OUT
  unstub git
}