Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
00f37d67
Unverified
Commit
00f37d67
authored
8 years ago
by
Vlad Shablinsky
Committed by
Xu Cheng
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Apply and add new download strategy tests
parent
5ddee350
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Library/Homebrew/test/test_download_strategies.rb
+55
-13
55 additions, 13 deletions
Library/Homebrew/test/test_download_strategies.rb
with
55 additions
and
13 deletions
Library/Homebrew/test/test_download_strategies.rb
+
55
−
13
View file @
00f37d67
...
...
@@ -69,7 +69,6 @@ class GitDownloadStrategyTests < Homebrew::TestCase
@strategy
=
GitDownloadStrategy
.
new
(
"baz"
,
resource
)
@cached_location
=
@strategy
.
cached_location
mkpath
@cached_location
touch
@cached_location
/
"README"
end
def
teardown
...
...
@@ -84,30 +83,39 @@ class GitDownloadStrategyTests < Homebrew::TestCase
end
end
def
inside_repo_
using_git_env
def
using_git_env
initial_env
=
ENV
.
to_hash
%w[AUTHOR COMMITTER]
.
each
do
|
role
|
ENV
[
"GIT_
#{
role
}
_NAME"
]
=
"brew tests"
ENV
[
"GIT_
#{
role
}
_EMAIL"
]
=
"brew-tests@localhost"
ENV
[
"GIT_
#{
role
}
_DATE"
]
=
"Thu May 21 00:04:11 2009 +0100"
end
@cached_location
.
cd
do
yield
end
yield
ensure
ENV
.
replace
(
initial_env
)
end
def
setup_git_repo
inside_repo_using_git_env
do
shutup
do
system
"git"
,
"init"
system
"git"
,
"remote"
,
"add"
,
"origin"
,
"https://github.com/Homebrew/homebrew-foo"
using_git_env
do
@cached_location
.
cd
do
shutup
do
system
"git"
,
"init"
system
"git"
,
"remote"
,
"add"
,
"origin"
,
"https://github.com/Homebrew/homebrew-foo"
end
touch
"README"
git_commit_all
end
git_commit_all
end
end
def
test_github_git_download_strategy_user_repo
resource
=
ResourceDouble
.
new
(
"https://github.com/homebrew/brew.git"
)
strategy
=
GitHubGitDownloadStrategy
.
new
(
"brew"
,
resource
)
assert_equal
strategy
.
instance_variable_get
(
:@user
),
"homebrew"
assert_equal
strategy
.
instance_variable_get
(
:@repo
),
"brew"
end
def
test_source_modified_time
setup_git_repo
assert_equal
1242860651
,
@strategy
.
source_modified_time
.
to_i
...
...
@@ -115,12 +123,41 @@ class GitDownloadStrategyTests < Homebrew::TestCase
def
test_last_commit
setup_git_repo
inside_repo_using_git_env
do
touch
"LICENSE"
git_commit_all
using_git_env
do
@cached_location
.
cd
do
touch
"LICENSE"
git_commit_all
end
end
assert_equal
"c50c79b"
,
@strategy
.
last_commit
end
def
test_fetch_last_commit
remote_repo
=
HOMEBREW_PREFIX
.
join
(
"remote_repo"
)
remote_repo
.
mkdir
resource
=
ResourceDouble
.
new
(
"file://
#{
remote_repo
}
"
)
resource
.
instance_variable_set
(
:@version
,
Version
.
create
(
"HEAD"
))
@strategy
=
GitDownloadStrategy
.
new
(
"baz"
,
resource
)
using_git_env
do
remote_repo
.
cd
do
shutup
do
system
"git"
,
"init"
system
"git"
,
"remote"
,
"add"
,
"origin"
,
"https://github.com/Homebrew/homebrew-foo"
end
touch
"README"
git_commit_all
touch
"LICENSE"
git_commit_all
end
end
@strategy
.
shutup!
assert_equal
"c50c79b"
,
@strategy
.
fetch_last_commit
ensure
remote_repo
.
rmtree
if
remote_repo
.
directory?
end
end
class
DownloadStrategyDetectorTests
<
Homebrew
::
TestCase
...
...
@@ -133,6 +170,11 @@ class DownloadStrategyDetectorTests < Homebrew::TestCase
assert_equal
GitDownloadStrategy
,
@d
end
def
test_detect_github_git_download_strategy
@d
=
DownloadStrategyDetector
.
detect
(
"https://github.com/homebrew/brew.git"
)
assert_equal
GitHubGitDownloadStrategy
,
@d
end
def
test_default_to_curl_strategy
@d
=
DownloadStrategyDetector
.
detect
(
Object
.
new
)
assert_equal
CurlDownloadStrategy
,
@d
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment