瀏覽代碼

Make tests pass

Tests have broken as locks were expanded and auto-filled newer versions
of lockfiles. This fixes them back.
pull/1207/head
Fred Hebert 9 年之前
父節點
當前提交
00e06c1999
共有 3 個檔案被更改,包括 18 行新增11 行删除
  1. +7
    -7
      test/rebar_pkg_SUITE.erl
  2. +3
    -3
      test/rebar_pkg_alias_SUITE.erl
  3. +8
    -1
      test/rebar_upgrade_SUITE.erl

+ 7
- 7
test/rebar_pkg_SUITE.erl 查看文件

@ -103,7 +103,7 @@ good_uncached(Config) ->
{Pkg,Vsn} = ?config(pkg, Config),
State = ?config(state, Config),
?assertEqual({ok, true},
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, undefined}, State)),
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, ?good_checksum}, State)),
Cache = ?config(cache_dir, Config),
?assert(filelib:is_regular(filename:join(Cache, <<Pkg/binary, "-", Vsn/binary, ".tar">>))).
@ -116,7 +116,7 @@ good_cached(Config) ->
?assert(filelib:is_regular(CachedFile)),
{ok, Content} = file:read_file(CachedFile),
?assertEqual({ok, true},
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, undefined}, State)),
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, ?good_checksum}, State)),
{ok, Content} = file:read_file(CachedFile).
badindexchk(Config) ->
@ -124,7 +124,7 @@ badindexchk(Config) ->
{Pkg,Vsn} = ?config(pkg, Config),
State = ?config(state, Config),
?assertMatch({bad_registry_checksum, _Path},
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, undefined}, State)),
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, ?good_checksum}, State)),
%% The cached file is there for forensic purposes
Cache = ?config(cache_dir, Config),
?assert(filelib:is_regular(filename:join(Cache, <<Pkg/binary, "-", Vsn/binary, ".tar">>))).
@ -134,7 +134,7 @@ badpkg(Config) ->
{Pkg,Vsn} = ?config(pkg, Config),
State = ?config(state, Config),
?assertMatch({bad_download, _Path},
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, undefined}, State)),
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, ?good_checksum}, State)),
%% The cached file is there for forensic purposes
Cache = ?config(cache_dir, Config),
?assert(filelib:is_regular(filename:join(Cache, <<Pkg/binary, "-", Vsn/binary, ".tar">>))).
@ -148,7 +148,7 @@ bad_to_good(Config) ->
?assert(filelib:is_regular(CachedFile)),
{ok, Contents} = file:read_file(CachedFile),
?assertEqual({ok, true},
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, undefined}, State)),
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, ?good_checksum}, State)),
%% Cache has refreshed
?assert({ok, Contents} =/= file:read_file(CachedFile)).
@ -161,7 +161,7 @@ good_disconnect(Config) ->
?assert(filelib:is_regular(CachedFile)),
{ok, Content} = file:read_file(CachedFile),
?assertEqual({ok, true},
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, undefined}, State)),
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, ?good_checksum}, State)),
{ok, Content} = file:read_file(CachedFile).
bad_disconnect(Config) ->
@ -169,7 +169,7 @@ bad_disconnect(Config) ->
{Pkg,Vsn} = ?config(pkg, Config),
State = ?config(state, Config),
?assertEqual({fetch_fail, Pkg, Vsn},
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, undefined}, State)).
rebar_pkg_resource:download(Tmp, {pkg, Pkg, Vsn, ?good_checksum}, State)).
pkgs_provider(Config) ->
Config1 = rebar_test_utils:init_rebar_state(Config),

+ 3
- 3
test/rebar_pkg_alias_SUITE.erl 查看文件

@ -55,7 +55,7 @@ diff_alias(Config) ->
Config, RebarConfig, ["lock"],
{ok, [{lock, "fakelib"},{dep, "fakelib"}]}
),
{ok, [LockData]} = file:consult(Lockfile),
{ok, [{_Vsn, LockData}|_]} = file:consult(Lockfile),
?assert(lists:any(fun({<<"fakelib">>,{pkg,<<"goodpkg">>,_},_}) -> true
; (_) -> false end, LockData)),
%% An second run yields the same
@ -63,13 +63,13 @@ diff_alias(Config) ->
Config, RebarConfig, ["lock"],
{ok, [{lock, "fakelib"},{dep, "fakelib"}]}
),
{ok, [LockData]} = file:consult(Lockfile),
{ok, [{_Vsn, LockData}|_]} = file:consult(Lockfile),
%% So does an upgrade
rebar_test_utils:run_and_check(
Config, RebarConfig, ["upgrade"],
{ok, [{lock, "fakelib"},{dep, "fakelib"}]}
),
{ok, [LockData]} = file:consult(Lockfile).
{ok, [{_Vsn, LockData}|_]} = file:consult(Lockfile).
diff_alias_vsn(Config) -> diff_alias(Config).

+ 8
- 1
test/rebar_upgrade_SUITE.erl 查看文件

@ -610,7 +610,14 @@ novsn_pkg(Config) ->
rewrite_locks({ok, Expectations}, Config) ->
AppDir = ?config(apps, Config),
LockFile = filename:join([AppDir, "rebar.lock"]),
{ok, [Locks]} = file:consult(LockFile),
Locks = case ?config(deps_type, Config) of
git ->
{ok, [LockData]} = file:consult(LockFile),
LockData;
pkg ->
{ok, [{_Vsn, LockData}|_]} = file:consult(LockFile),
LockData
end,
ExpLocks = [{list_to_binary(Name), Vsn}
|| {lock, Name, Vsn} <- Expectations],
NewLocks = lists:foldl(

Loading…
取消
儲存