Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

tests: Add missing version tests #49031

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Library/Homebrew/test/test_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,32 @@ def test_raises_for_non_string_objects
assert_raises(TypeError) { Version.new(1) }
assert_raises(TypeError) { Version.new(:symbol) }
end

def test_detected_from_url?
refute Version.new("1.0").detected_from_url?
assert Version::FromURL.new("1.0").detected_from_url?
end
end

class VersionTokenTests < Homebrew::TestCase
def test_inspect
assert_equal '#<Version::Token "foo">',
Version::Token.new("foo").inspect
end

def test_to_s
assert_equal "foo", Version::Token.new("foo").to_s
end
end

class VersionNullTokenTests < Homebrew::TestCase
def test_inspect
assert_equal "#<Version::NullToken>", Version::NullToken.new.inspect
end

def test_comparing_null
assert_operator Version::NullToken.new, :==, Version::NullToken.new
end
end

class VersionComparisonTests < Homebrew::TestCase
Expand Down Expand Up @@ -404,4 +430,9 @@ def test_waf_version
def test_dash_separated_version
assert_version_detected "6-20151227", "ftp://gcc.gnu.org/pub/gcc/snapshots/6-20151227/gcc-6-20151227.tar.bz2"
end

def test_from_url
assert_version_detected "1.2.3",
"http://github.com/foo/bar.git", {:tag => "v1.2.3"}
end
end
4 changes: 2 additions & 2 deletions Library/Homebrew/test/testing_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def assert_version_equal(expected, actual)
assert_equal Version.new(expected), actual
end

def assert_version_detected(expected, url)
assert_equal expected, Version.parse(url).to_s
def assert_version_detected(expected, url, specs={})
assert_equal expected, Version.detect(url, specs).to_s
end

def assert_version_nil(url)
Expand Down