2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2021-06-01 23:32:47 -04:00
|
|
|
require_relative 'helper'
|
2013-09-09 20:52:14 -04:00
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
class TestGemResolverIndexSet < Gem::TestCase
|
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
|
2014-09-13 23:30:02 -04:00
|
|
|
|
|
|
|
refute_empty set.errors
|
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
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
set = @DR::IndexSet.new
|
2014-02-03 19:48:31 -05:00
|
|
|
|
|
|
|
dependency = dep 'a', '~> 1'
|
|
|
|
|
|
|
|
req = @DR::DependencyRequest.new dependency, nil
|
|
|
|
|
|
|
|
found = set.find_all req
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
assert_equal %w[a-1], found.map {|s| s.full_name }
|
2014-02-03 19:48:31 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_find_all_local
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', 1
|
|
|
|
fetcher.spec 'a', 2
|
|
|
|
fetcher.spec 'b', 1
|
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
set = @DR::IndexSet.new
|
2014-02-03 19:48:31 -05:00
|
|
|
set.remote = false
|
|
|
|
|
|
|
|
dependency = dep 'a', '~> 1'
|
|
|
|
|
|
|
|
req = @DR::DependencyRequest.new dependency, nil
|
|
|
|
|
|
|
|
assert_empty set.find_all req
|
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def test_find_all_prerelease
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.spec 'a', '1.a'
|
|
|
|
end
|
|
|
|
|
|
|
|
set = @DR::IndexSet.new
|
|
|
|
|
|
|
|
dependency = dep 'a'
|
|
|
|
|
|
|
|
req = @DR::DependencyRequest.new dependency, nil
|
|
|
|
|
|
|
|
found = set.find_all req
|
|
|
|
|
|
|
|
assert_empty found
|
|
|
|
|
|
|
|
dependency.prerelease = true
|
|
|
|
|
|
|
|
req = @DR::DependencyRequest.new dependency, nil
|
|
|
|
|
|
|
|
found = set.find_all req
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
assert_equal %w[a-1.a], found.map {|s| s.full_name }
|
2014-09-13 23:30:02 -04:00
|
|
|
end
|
2013-09-09 20:52:14 -04:00
|
|
|
end
|