Skip to content

Commit

Permalink
consistently format unreachable_package
Browse files Browse the repository at this point in the history
* Unreachable package always returns as {error, {unreachable_package, Package} }
  from ``depsolver:solve``
* correct vim modelines
* add test coverage for incorrect unreachable_package response
  • Loading branch information
marcparadise committed Jun 11, 2013
1 parent a2ae719 commit ac6b159
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/depsolver.erl
@@ -1,5 +1,5 @@
%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%% ex: ts=4 sx=4 et
%% ex: ts=4 sw=4 et
%%
%% Copyright 2012 Opscode, Inc. All Rights Reserved.
%%
Expand Down
6 changes: 3 additions & 3 deletions src/depsolver_culprit.erl
@@ -1,5 +1,5 @@
%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%% ex: ts=4 sx=4 et
%% ex: ts=4 sw=4 et
%%
%% @author Eric Merritt <ericbmerritt@gmail.com>
%%
Expand Down Expand Up @@ -53,7 +53,7 @@ search(State, ActiveCons, []) ->
{fail, FailPaths} ->
extract_culprit_information0(ActiveCons, lists:flatten(FailPaths));
{missing, Pkg} ->
{error, {unreachable_package, Pkg}};
{unreachable_package, Pkg};
_Success ->
%% This should *never* happen. 'Culprit' above represents the last
%% possible constraint that could cause things to fail. There for
Expand All @@ -65,7 +65,7 @@ search(State, ActiveCons, [NewCon | Constraints]) ->
{fail, FailPaths} ->
extract_culprit_information0(ActiveCons, lists:flatten(FailPaths));
{missing, Pkg} ->
{error, {unreachable_package, Pkg}};
{unreachable_package, Pkg};
_Success ->
%% Move one constraint from the inactive to the active
%% constraints and run again
Expand Down
11 changes: 9 additions & 2 deletions test/depsolver_tests.erl
@@ -1,5 +1,5 @@
%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%% ex: ts=4 sx=4 et
%% ex: ts=4 sw=4 et
%%
%%-------------------------------------------------------------------
%% Copyright 2012 Opscode, Inc. All Rights Reserved.
Expand Down Expand Up @@ -52,6 +52,7 @@ all_test_() ->
{?MODULE, not_new_enough},
{?MODULE, impossible_dependency},
{?MODULE, integration},
{?MODULE, missing_via_culprit_search},
{generator, ?MODULE, format},
{generator, ?MODULE, missing2}
]
Expand Down Expand Up @@ -479,7 +480,6 @@ filter_versions() ->

-spec missing() -> ok.
missing() ->

Dom0 = depsolver:add_packages(depsolver:new_graph(), [{app1, [{"0.1", [{app2, "0.2"},
{app3, "0.2", '>='},
{app4, "0.2", '='}]},
Expand All @@ -500,6 +500,13 @@ missing() ->
?assertMatch({error,_},
Ret2).

missing_via_culprit_search() ->
World = [{<<"app1">>,[{"1.1.0",[]}]},
{<<"app2">>,[{"0.0.1",[{<<"app1::oops">>,<<"0.0.0">>,'>='}]} ]} ],
Dom0 = depsolver:add_packages(depsolver:new_graph(), World),
Ret1 = depsolver:solve(Dom0, [<<"app1">>,<<"app2">>]),
_ = depsolver:format_error(Ret1),
?assertMatch({error,{unreachable_package,<<"app1::oops">>}}, Ret1).

binary() ->

Expand Down

0 comments on commit ac6b159

Please sign in to comment.