2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2021-06-01 23:32:47 -04:00
|
|
|
require_relative 'helper'
|
2013-07-09 19:21:36 -04:00
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
class TestGemResolverConflict < Gem::TestCase
|
2013-07-09 19:21:36 -04:00
|
|
|
def test_explanation
|
|
|
|
root =
|
|
|
|
dependency_request dep('net-ssh', '>= 2.0.13'), 'rye', '0.9.8'
|
2013-07-09 19:41:44 -04:00
|
|
|
child =
|
2013-07-09 19:21:36 -04:00
|
|
|
dependency_request dep('net-ssh', '>= 2.6.5'), 'net-ssh', '2.2.2', root
|
|
|
|
|
2013-11-21 18:27:30 -05:00
|
|
|
dep = Gem::Resolver::DependencyRequest.new dep('net-ssh', '>= 2.0.13'), nil
|
|
|
|
|
2017-10-07 21:32:18 -04:00
|
|
|
spec = util_spec 'net-ssh', '2.2.2'
|
2013-11-21 18:27:30 -05:00
|
|
|
active =
|
|
|
|
Gem::Resolver::ActivationRequest.new spec, dep
|
|
|
|
|
2013-07-09 19:21:36 -04:00
|
|
|
conflict =
|
2013-11-21 18:27:30 -05:00
|
|
|
Gem::Resolver::Conflict.new child, active
|
2013-07-09 19:21:36 -04:00
|
|
|
|
|
|
|
expected = <<-EXPECTED
|
2014-09-13 23:30:02 -04:00
|
|
|
Activated net-ssh-2.2.2
|
|
|
|
which does not match conflicting dependency (>= 2.6.5)
|
|
|
|
|
|
|
|
Conflicting dependency chains:
|
|
|
|
net-ssh (>= 2.0.13), 2.2.2 activated
|
|
|
|
|
|
|
|
versus:
|
|
|
|
rye (= 0.9.8), 0.9.8 activated, depends on
|
|
|
|
net-ssh (>= 2.0.13), 2.2.2 activated, depends on
|
|
|
|
net-ssh (>= 2.6.5)
|
|
|
|
|
2013-07-09 19:21:36 -04:00
|
|
|
EXPECTED
|
|
|
|
|
|
|
|
assert_equal expected, conflict.explanation
|
|
|
|
end
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
def test_explanation_user_request
|
2013-11-18 19:34:13 -05:00
|
|
|
@DR = Gem::Resolver
|
2013-11-10 12:51:40 -05:00
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
spec = util_spec 'a', 2
|
2013-11-10 12:51:40 -05:00
|
|
|
|
|
|
|
a1_req = @DR::DependencyRequest.new dep('a', '= 1'), nil
|
|
|
|
a2_req = @DR::DependencyRequest.new dep('a', '= 2'), nil
|
|
|
|
|
|
|
|
activated = @DR::ActivationRequest.new spec, a2_req
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
conflict = @DR::Conflict.new a1_req, activated
|
2013-11-10 12:51:40 -05:00
|
|
|
|
|
|
|
expected = <<-EXPECTED
|
2014-09-13 23:30:02 -04:00
|
|
|
Activated a-2
|
|
|
|
which does not match conflicting dependency (= 1)
|
|
|
|
|
|
|
|
Conflicting dependency chains:
|
|
|
|
a (= 2), 2 activated
|
|
|
|
|
|
|
|
versus:
|
|
|
|
a (= 1)
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
EXPECTED
|
|
|
|
|
|
|
|
assert_equal expected, conflict.explanation
|
|
|
|
end
|
|
|
|
|
2013-07-09 19:21:36 -04:00
|
|
|
def test_request_path
|
|
|
|
root =
|
|
|
|
dependency_request dep('net-ssh', '>= 2.0.13'), 'rye', '0.9.8'
|
2013-11-21 18:27:30 -05:00
|
|
|
|
2013-07-09 19:41:44 -04:00
|
|
|
child =
|
2013-11-21 18:27:30 -05:00
|
|
|
dependency_request dep('other', '>= 1.0'), 'net-ssh', '2.2.2', root
|
2013-07-09 19:21:36 -04:00
|
|
|
|
|
|
|
conflict =
|
2013-11-21 18:27:30 -05:00
|
|
|
Gem::Resolver::Conflict.new nil, nil
|
|
|
|
|
|
|
|
expected = [
|
2014-09-13 23:30:02 -04:00
|
|
|
'net-ssh (>= 2.0.13), 2.2.2 activated',
|
2020-12-08 02:33:39 -05:00
|
|
|
'rye (= 0.9.8), 0.9.8 activated',
|
2013-11-21 18:27:30 -05:00
|
|
|
]
|
2013-07-09 19:21:36 -04:00
|
|
|
|
2013-11-21 18:27:30 -05:00
|
|
|
assert_equal expected, conflict.request_path(child.requester)
|
2013-07-09 19:21:36 -04:00
|
|
|
end
|
|
|
|
end
|