2013-09-09 20:52:14 -04:00
|
|
|
require 'rubygems/test_case'
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
class TestGemResolverIndexSet < Gem::TestCase
|
2013-09-09 20:52:14 -04:00
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
def setup
|
|
|
|
super
|
2013-09-09 20:52:14 -04:00
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
@DR = Gem::Resolver
|
2013-09-09 20:52:14 -04:00
|
|
|
end
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
def test_initialize
|
|
|
|
set = @DR::IndexSet.new
|
2013-09-09 20:52:14 -04:00
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
fetcher = set.instance_variable_get :@f
|
2013-09-09 20:52:14 -04:00
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
assert_same Gem::SpecFetcher.fetcher, fetcher
|
|
|
|
end
|
2013-09-09 20:52:14 -04:00
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
def test_initialize_source
|
|
|
|
set = @DR::IndexSet.new 'http://alternate.example'
|
2013-09-09 20:52:14 -04:00
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
fetcher = set.instance_variable_get :@f
|
2013-09-09 20:52:14 -04:00
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
refute_same Gem::SpecFetcher.fetcher, fetcher
|
2013-09-09 20:52:14 -04:00
|
|
|
end
|
|
|
|
|
2014-02-03 19:48:31 -05: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-09 20:52:14 -04:00
|
|
|
end
|
|
|
|
|