2013-09-10 04:52:14 +04:00
|
|
|
require 'rubygems/test_case'
|
|
|
|
|
2013-11-19 04:34:13 +04:00
|
|
|
class TestGemResolverIndexSet < Gem::TestCase
|
2013-09-10 04:52:14 +04:00
|
|
|
|
2013-11-10 21:51:40 +04:00
|
|
|
def setup
|
|
|
|
super
|
2013-09-10 04:52:14 +04:00
|
|
|
|
2013-11-19 04:34:13 +04:00
|
|
|
@DR = Gem::Resolver
|
2013-09-10 04:52:14 +04:00
|
|
|
end
|
|
|
|
|
2013-11-10 21:51:40 +04:00
|
|
|
def test_initialize
|
|
|
|
set = @DR::IndexSet.new
|
2013-09-10 04:52:14 +04:00
|
|
|
|
2013-11-10 21:51:40 +04:00
|
|
|
fetcher = set.instance_variable_get :@f
|
2013-09-10 04:52:14 +04:00
|
|
|
|
2013-11-10 21:51:40 +04:00
|
|
|
assert_same Gem::SpecFetcher.fetcher, fetcher
|
|
|
|
end
|
2013-09-10 04:52:14 +04:00
|
|
|
|
2013-11-10 21:51:40 +04:00
|
|
|
def test_initialize_source
|
|
|
|
set = @DR::IndexSet.new 'http://alternate.example'
|
2013-09-10 04:52:14 +04:00
|
|
|
|
2013-11-10 21:51:40 +04:00
|
|
|
fetcher = set.instance_variable_get :@f
|
2013-09-10 04:52:14 +04:00
|
|
|
|
2013-11-10 21:51:40 +04:00
|
|
|
refute_same Gem::SpecFetcher.fetcher, fetcher
|
2013-09-10 04:52:14 +04:00
|
|
|
end
|
|
|
|
|
2014-02-04 04:48:31 +04:00
|
|
|
def test_find_all
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 1
|
|
|
|
fetcher.spec 'a', 2
|
|
|
|
fetcher.spec 'b', 1
|
|
|
|
end
|
|
|
|
|
|
|
|
set = @DR::BestSet.new
|
|
|
|
|
|
|
|
dependency = dep 'a', '~> 1'
|
|
|
|
|
|
|
|
req = @DR::DependencyRequest.new dependency, nil
|
|
|
|
|
|
|
|
found = set.find_all req
|
|
|
|
|
|
|
|
assert_equal %w[a-1], found.map { |s| s.full_name }
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_find_all_local
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 1
|
|
|
|
fetcher.spec 'a', 2
|
|
|
|
fetcher.spec 'b', 1
|
|
|
|
end
|
|
|
|
|
|
|
|
set = @DR::BestSet.new
|
|
|
|
set.remote = false
|
|
|
|
|
|
|
|
dependency = dep 'a', '~> 1'
|
|
|
|
|
|
|
|
req = @DR::DependencyRequest.new dependency, nil
|
|
|
|
|
|
|
|
assert_empty set.find_all req
|
|
|
|
end
|
|
|
|
|
2013-09-10 04:52:14 +04:00
|
|
|
end
|
|
|
|
|