|
@ -99,7 +99,7 @@ init_per_testcase(bad_disconnect=Name, Config0) -> |
|
|
Config = mock_config(Name, Config1), |
|
|
Config = mock_config(Name, Config1), |
|
|
meck:expect(hex_repo, get_tarball, fun(_, _, _) -> |
|
|
meck:expect(hex_repo, get_tarball, fun(_, _, _) -> |
|
|
{error, econnrefused} |
|
|
{error, econnrefused} |
|
|
end), |
|
|
|
|
|
|
|
|
end), |
|
|
Config; |
|
|
Config; |
|
|
init_per_testcase(Name, Config0) -> |
|
|
init_per_testcase(Name, Config0) -> |
|
|
Config = [{good_cache, false}, |
|
|
Config = [{good_cache, false}, |
|
@ -252,7 +252,7 @@ mock_config(Name, Config) -> |
|
|
CacheRoot = filename:join([Priv, "cache", atom_to_list(Name)]), |
|
|
CacheRoot = filename:join([Priv, "cache", atom_to_list(Name)]), |
|
|
TmpDir = filename:join([Priv, "tmp", atom_to_list(Name)]), |
|
|
TmpDir = filename:join([Priv, "tmp", atom_to_list(Name)]), |
|
|
Tid = ets:new(registry_table, [public]), |
|
|
Tid = ets:new(registry_table, [public]), |
|
|
AllDeps = [ |
|
|
|
|
|
|
|
|
AllDeps = [ |
|
|
{{<<"badindexchk">>,<<"1.0.0">>}, [[], ?bad_checksum, [<<"rebar3">>]]}, |
|
|
{{<<"badindexchk">>,<<"1.0.0">>}, [[], ?bad_checksum, [<<"rebar3">>]]}, |
|
|
{{<<"goodpkg">>,<<"1.0.0">>}, [[], ?good_checksum, [<<"rebar3">>]]}, |
|
|
{{<<"goodpkg">>,<<"1.0.0">>}, [[], ?good_checksum, [<<"rebar3">>]]}, |
|
|
{{<<"goodpkg">>,<<"1.0.1">>}, [[], ?good_checksum, [<<"rebar3">>]]}, |
|
|
{{<<"goodpkg">>,<<"1.0.1">>}, [[], ?good_checksum, [<<"rebar3">>]]}, |
|
@ -267,7 +267,7 @@ mock_config(Name, Config) -> |
|
|
ok = ets:tab2file(Tid, filename:join([CacheDir, "registry"])), |
|
|
ok = ets:tab2file(Tid, filename:join([CacheDir, "registry"])), |
|
|
|
|
|
|
|
|
catch ets:delete(?PACKAGE_TABLE), |
|
|
catch ets:delete(?PACKAGE_TABLE), |
|
|
rebar_packages:new_package_table(), |
|
|
|
|
|
|
|
|
rebar_packages:new_package_table(), |
|
|
lists:foreach(fun({{N, Vsn}, [Deps, Checksum, _]}) -> |
|
|
lists:foreach(fun({{N, Vsn}, [Deps, Checksum, _]}) -> |
|
|
case ets:member(?PACKAGE_TABLE, {ec_cnv:to_binary(N), Vsn, <<"hexpm">>}) of |
|
|
case ets:member(?PACKAGE_TABLE, {ec_cnv:to_binary(N), Vsn, <<"hexpm">>}) of |
|
|
false -> |
|
|
false -> |
|
@ -279,18 +279,18 @@ mock_config(Name, Config) -> |
|
|
ok |
|
|
ok |
|
|
end |
|
|
end |
|
|
end, AllDeps), |
|
|
end, AllDeps), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
meck:new(hex_repo, [passthrough]), |
|
|
meck:new(hex_repo, [passthrough]), |
|
|
meck:expect(hex_repo, get_package, |
|
|
|
|
|
|
|
|
meck:expect(hex_repo, get_package, |
|
|
fun(_Config, PkgName) -> |
|
|
fun(_Config, PkgName) -> |
|
|
Matches = ets:match_object(Tid, {{PkgName,'_'}, '_'}), |
|
|
Matches = ets:match_object(Tid, {{PkgName,'_'}, '_'}), |
|
|
Releases = |
|
|
|
|
|
|
|
|
Releases = |
|
|
[#{checksum => Checksum, |
|
|
[#{checksum => Checksum, |
|
|
version => Vsn, |
|
|
version => Vsn, |
|
|
dependencies => Deps} || |
|
|
|
|
|
|
|
|
dependencies => Deps} || |
|
|
{{_, Vsn}, [Deps, Checksum, _]} <- Matches], |
|
|
{{_, Vsn}, [Deps, Checksum, _]} <- Matches], |
|
|
{ok, {200, #{}, #{releases => Releases}}} |
|
|
|
|
|
|
|
|
{ok, {200, #{}, Releases}} |
|
|
end), |
|
|
end), |
|
|
|
|
|
|
|
|
%% The state returns us a fake registry |
|
|
%% The state returns us a fake registry |
|
@ -321,7 +321,7 @@ mock_config(Name, Config) -> |
|
|
%% Cache fetches are mocked -- we assume the server and clients are |
|
|
%% Cache fetches are mocked -- we assume the server and clients are |
|
|
%% correctly used. |
|
|
%% correctly used. |
|
|
GoodCache = ?config(good_cache, Config), |
|
|
GoodCache = ?config(good_cache, Config), |
|
|
{Pkg,Vsn} = ?config(pkg, Config), |
|
|
|
|
|
|
|
|
{Pkg,Vsn} = ?config(pkg, Config), |
|
|
PkgFile = <<Pkg/binary, "-", Vsn/binary, ".tar">>, |
|
|
PkgFile = <<Pkg/binary, "-", Vsn/binary, ".tar">>, |
|
|
{ok, PkgContents} = file:read_file(filename:join(?config(data_dir, Config), PkgFile)), |
|
|
{ok, PkgContents} = file:read_file(filename:join(?config(data_dir, Config), PkgFile)), |
|
|
|
|
|
|
|
@ -329,8 +329,8 @@ mock_config(Name, Config) -> |
|
|
{ok, {304, #{<<"etag">> => ?good_etag}, <<>>}}; |
|
|
{ok, {304, #{<<"etag">> => ?good_etag}, <<>>}}; |
|
|
(_, _, _) -> |
|
|
(_, _, _) -> |
|
|
{ok, {200, #{<<"etag">> => ?good_etag}, PkgContents}} |
|
|
{ok, {200, #{<<"etag">> => ?good_etag}, PkgContents}} |
|
|
end), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end), |
|
|
|
|
|
|
|
|
[{cache_root, CacheRoot}, |
|
|
[{cache_root, CacheRoot}, |
|
|
{cache_dir, CacheDir}, |
|
|
{cache_dir, CacheDir}, |
|
|
{tmp_dir, TmpDir}, |
|
|
{tmp_dir, TmpDir}, |
|
|