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
3793c058
Commit
3793c058
authored
11 years ago
by
Jack Nagel
Browse files
Options
Downloads
Patches
Plain Diff
SoftwareSpec tests are now Resource tests
parent
eb307133
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/test/test_resource.rb
+122
-0
122 additions, 0 deletions
Library/Homebrew/test/test_resource.rb
Library/Homebrew/test/test_software_spec.rb
+0
-120
0 additions, 120 deletions
Library/Homebrew/test/test_software_spec.rb
with
122 additions
and
120 deletions
Library/Homebrew/test/test_resource.rb
0 → 100644
+
122
−
0
View file @
3793c058
require
'testing_env'
require
'resource'
class
ResourceTests
<
Test
::
Unit
::
TestCase
include
VersionAssertions
def
setup
@resource
=
Resource
.
new
(
'test'
)
end
def
test_url
@resource
.
url
(
'foo'
)
assert_equal
'foo'
,
@resource
.
url
end
def
test_url_with_specs
@resource
.
url
(
'foo'
,
:branch
=>
'master'
)
assert_equal
'foo'
,
@resource
.
url
assert_equal
({
:branch
=>
'master'
},
@resource
.
specs
)
end
def
test_url_with_custom_download_strategy_class
strategy
=
Class
.
new
(
AbstractDownloadStrategy
)
@resource
.
url
(
'foo'
,
:using
=>
strategy
)
assert_equal
'foo'
,
@resource
.
url
assert_equal
strategy
,
@resource
.
download_strategy
end
def
test_url_with_specs_and_download_strategy
strategy
=
Class
.
new
(
AbstractDownloadStrategy
)
@resource
.
url
(
'foo'
,
:using
=>
strategy
,
:branch
=>
'master'
)
assert_equal
'foo'
,
@resource
.
url
assert_equal
({
:branch
=>
'master'
},
@resource
.
specs
)
assert_equal
strategy
,
@resource
.
download_strategy
end
def
test_url_with_custom_download_strategy_symbol
@resource
.
url
(
'foo'
,
:using
=>
:git
)
assert_equal
'foo'
,
@resource
.
url
assert_equal
GitDownloadStrategy
,
@resource
.
download_strategy
end
def
test_version
@resource
.
version
(
'1.0'
)
assert_version_equal
'1.0'
,
@resource
.
version
assert
!
@resource
.
version
.
detected_from_url?
end
def
test_version_from_url
@resource
.
url
(
'http://foo.com/bar-1.0.tar.gz'
)
assert_version_equal
'1.0'
,
@resource
.
version
assert
@resource
.
version
.
detected_from_url?
end
def
test_version_with_scheme
scheme
=
Class
.
new
(
Version
)
@resource
.
version
(
'1.0'
=>
scheme
)
assert_version_equal
'1.0'
,
@resource
.
version
assert_instance_of
scheme
,
@resource
.
version
end
def
test_version_from_tag
@resource
.
url
(
'http://foo.com/bar-1.0.tar.gz'
,
:tag
=>
'v1.0.2'
)
assert_version_equal
'1.0.2'
,
@resource
.
version
assert
@resource
.
version
.
detected_from_url?
end
def
test_rejects_non_string_versions
assert_raises
(
TypeError
)
{
@resource
.
version
(
1
)
}
assert_raises
(
TypeError
)
{
@resource
.
version
(
2.0
)
}
assert_raises
(
TypeError
)
{
@resource
.
version
(
Object
.
new
)
}
end
def
test_mirrors
assert_empty
@resource
.
mirrors
@resource
.
mirror
(
'foo'
)
@resource
.
mirror
(
'bar'
)
assert_equal
'foo'
,
@resource
.
mirrors
.
shift
assert_equal
'bar'
,
@resource
.
mirrors
.
shift
end
def
test_checksum_setters
assert_nil
@resource
.
checksum
@resource
.
sha1
(
'baadidea'
*
5
)
assert_equal
Checksum
.
new
(
:sha1
,
'baadidea'
*
5
),
@resource
.
checksum
@resource
.
sha256
(
'baadidea'
*
8
)
assert_equal
Checksum
.
new
(
:sha256
,
'baadidea'
*
8
),
@resource
.
checksum
end
def
test_download_strategy
strategy
=
Object
.
new
DownloadStrategyDetector
.
expects
(
:detect
).
with
(
"foo"
,
nil
).
returns
(
strategy
)
@resource
.
url
(
"foo"
)
assert_equal
strategy
,
@resource
.
download_strategy
end
def
test_verify_download_integrity_missing
fn
=
Pathname
.
new
(
'test'
)
checksum
=
@resource
.
sha1
(
'baadidea'
*
5
)
fn
.
expects
(
:verify_checksum
).
with
(
checksum
).
raises
(
ChecksumMissingError
)
fn
.
expects
(
:sha1
)
shutup
{
@resource
.
verify_download_integrity
(
fn
)
}
end
def
test_verify_download_integrity_mismatch
fn
=
Object
.
new
checksum
=
@resource
.
sha1
(
'baadidea'
*
5
)
fn
.
expects
(
:verify_checksum
).
with
(
checksum
).
raises
(
ChecksumMismatchError
.
new
(
checksum
,
Object
.
new
))
shutup
do
assert_raises
(
ChecksumMismatchError
)
do
@resource
.
verify_download_integrity
(
fn
)
end
end
end
end
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/test_software_spec.rb
+
0
−
120
View file @
3793c058
...
...
@@ -2,126 +2,6 @@ require 'testing_env'
require
'software_spec'
require
'bottles'
class
SoftwareSpecTests
<
Test
::
Unit
::
TestCase
include
VersionAssertions
def
setup
@spec
=
SoftwareSpec
.
new
end
def
test_url
@spec
.
url
(
'foo'
)
assert_equal
'foo'
,
@spec
.
url
end
def
test_url_with_specs
@spec
.
url
(
'foo'
,
:branch
=>
'master'
)
assert_equal
'foo'
,
@spec
.
url
assert_equal
({
:branch
=>
'master'
},
@spec
.
specs
)
end
def
test_url_with_custom_download_strategy_class
strategy
=
Class
.
new
(
AbstractDownloadStrategy
)
@spec
.
url
(
'foo'
,
:using
=>
strategy
)
assert_equal
'foo'
,
@spec
.
url
assert_equal
strategy
,
@spec
.
download_strategy
end
def
test_url_with_specs_and_download_strategy
strategy
=
Class
.
new
(
AbstractDownloadStrategy
)
@spec
.
url
(
'foo'
,
:using
=>
strategy
,
:branch
=>
'master'
)
assert_equal
'foo'
,
@spec
.
url
assert_equal
({
:branch
=>
'master'
},
@spec
.
specs
)
assert_equal
strategy
,
@spec
.
download_strategy
end
def
test_url_with_custom_download_strategy_symbol
@spec
.
url
(
'foo'
,
:using
=>
:git
)
assert_equal
'foo'
,
@spec
.
url
assert_equal
GitDownloadStrategy
,
@spec
.
download_strategy
end
def
test_version
@spec
.
version
(
'1.0'
)
assert_version_equal
'1.0'
,
@spec
.
version
assert
!
@spec
.
version
.
detected_from_url?
end
def
test_version_from_url
@spec
.
url
(
'http://foo.com/bar-1.0.tar.gz'
)
assert_version_equal
'1.0'
,
@spec
.
version
assert
@spec
.
version
.
detected_from_url?
end
def
test_version_with_scheme
scheme
=
Class
.
new
(
Version
)
@spec
.
version
(
'1.0'
=>
scheme
)
assert_version_equal
'1.0'
,
@spec
.
version
assert_instance_of
scheme
,
@spec
.
version
end
def
test_version_from_tag
@spec
.
url
(
'http://foo.com/bar-1.0.tar.gz'
,
:tag
=>
'v1.0.2'
)
assert_version_equal
'1.0.2'
,
@spec
.
version
assert
@spec
.
version
.
detected_from_url?
end
def
test_rejects_non_string_versions
assert_raises
(
TypeError
)
{
@spec
.
version
(
1
)
}
assert_raises
(
TypeError
)
{
@spec
.
version
(
2.0
)
}
assert_raises
(
TypeError
)
{
@spec
.
version
(
Object
.
new
)
}
end
def
test_mirrors
assert_empty
@spec
.
mirrors
@spec
.
mirror
(
'foo'
)
@spec
.
mirror
(
'bar'
)
assert_equal
'foo'
,
@spec
.
mirrors
.
shift
assert_equal
'bar'
,
@spec
.
mirrors
.
shift
end
def
test_checksum_setters
assert_nil
@spec
.
checksum
@spec
.
sha1
(
'baadidea'
*
5
)
assert_equal
Checksum
.
new
(
:sha1
,
'baadidea'
*
5
),
@spec
.
checksum
@spec
.
sha256
(
'baadidea'
*
8
)
assert_equal
Checksum
.
new
(
:sha256
,
'baadidea'
*
8
),
@spec
.
checksum
end
def
test_download_strategy
strategy
=
Object
.
new
DownloadStrategyDetector
.
expects
(
:detect
).
with
(
"foo"
,
nil
).
returns
(
strategy
)
@spec
.
url
(
"foo"
)
assert_equal
strategy
,
@spec
.
download_strategy
end
def
test_verify_download_integrity_missing
fn
=
Object
.
new
checksum
=
@spec
.
sha1
(
'baadidea'
*
5
)
fn
.
expects
(
:verify_checksum
).
with
(
checksum
).
raises
(
ChecksumMissingError
)
fn
.
expects
(
:sha1
)
shutup
{
@spec
.
verify_download_integrity
(
fn
)
}
end
def
test_verify_download_integrity_mismatch
fn
=
Object
.
new
checksum
=
@spec
.
sha1
(
'baadidea'
*
5
)
fn
.
expects
(
:verify_checksum
).
with
(
checksum
).
raises
(
ChecksumMismatchError
.
new
(
checksum
,
Object
.
new
))
shutup
do
assert_raises
(
ChecksumMismatchError
)
do
@spec
.
verify_download_integrity
(
fn
)
end
end
end
end
class
HeadSoftwareSpecTests
<
Test
::
Unit
::
TestCase
include
VersionAssertions
...
...
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