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
0b2cc5c2
Unverified
Commit
0b2cc5c2
authored
8 years ago
by
Vlad Shablinsky
Committed by
Xu Cheng
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
test_download_strategies: add git tests
parent
2f5f352b
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
+63
-0
63 additions, 0 deletions
Library/Homebrew/test/test_download_strategies.rb
with
63 additions
and
0 deletions
Library/Homebrew/test/test_download_strategies.rb
+
63
−
0
View file @
0b2cc5c2
...
...
@@ -60,6 +60,69 @@ class VCSDownloadStrategyTests < Homebrew::TestCase
end
end
class
GitDownloadStrategyTests
<
Homebrew
::
TestCase
include
FileUtils
def
setup
resource
=
ResourceDouble
.
new
(
"https://github.com/homebrew/foo"
)
@commit_id
=
1
@strategy
=
GitDownloadStrategy
.
new
(
"baz"
,
resource
)
@cached_location
=
@strategy
.
cached_location
mkpath
@cached_location
touch
@cached_location
/
"README"
end
def
teardown
rmtree
@cached_location
end
def
git_commit_all
shutup
do
system
"git"
,
"add"
,
"--all"
system
"git"
,
"commit"
,
"-m"
,
"commit number
#{
@commit_id
}
"
@commit_id
+=
1
end
end
def
inside_repo_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
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"
end
git_commit_all
end
end
def
test_source_modified_time
setup_git_repo
assert_equal
1242860651
,
@strategy
.
source_modified_time
.
to_i
end
def
test_last_commit
setup_git_repo
inside_repo_using_git_env
do
touch
"LICENSE"
git_commit_all
end
assert_equal
"c50c79b"
,
@strategy
.
last_commit
end
end
class
DownloadStrategyDetectorTests
<
Homebrew
::
TestCase
def
setup
@d
=
DownloadStrategyDetector
.
new
...
...
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