From 8229d15b6c8384e8d974b32d587b05d64fce185b Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 26 Feb 2018 15:31:42 -0800 Subject: rebar_package: do not return first package version for constraint with no match --- test/rebar_pkg_SUITE.erl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/rebar_pkg_SUITE.erl b/test/rebar_pkg_SUITE.erl index 32873c8..8ddf58f 100644 --- a/test/rebar_pkg_SUITE.erl +++ b/test/rebar_pkg_SUITE.erl @@ -226,7 +226,12 @@ find_highest_matching(_Config) -> ?assertEqual(<<"1.1.1">>, Vsn1), {ok, Vsn2} = rebar_packages:find_highest_matching( <<"test">>, <<"1.0.0">>, <<"goodpkg">>, <<"2.0">>, package_index, State), - ?assertEqual(<<"2.0.0">>, Vsn2). + ?assertEqual(<<"2.0.0">>, Vsn2), + + %% regression test. ~> constraints higher than the available packages would result + %% in returning the first package version instead of 'none'. + ?assertEqual(none, rebar_packages:find_highest_matching(<<"test">>, <<"1.0.0">>, <<"goodpkg">>, + <<"~> 5.0">>, package_index, State)). %%%%%%%%%%%%%%% @@ -267,6 +272,9 @@ mock_config(Name, Config) -> meck:expect(rebar_packages, package_dir, fun(_) -> {ok, CacheDir} end), rebar_prv_update:hex_to_index(rebar_state:new()), + meck:new(rebar_prv_update, [passthrough]), + meck:expect(rebar_prv_update, do, fun(State) -> {ok, State} end), + %% Cache fetches are mocked -- we assume the server and clients are %% correctly used. GoodCache = ?config(good_cache, Config), -- cgit v1.1