From 715c4b2360ed2768cb292f1c2055b1e24f76f624 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Wed, 13 May 2015 10:38:07 +0000 Subject: Update mock so existing tests pass --- test/mock_pkg_resource.erl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/mock_pkg_resource.erl b/test/mock_pkg_resource.erl index 560caef..e94ea93 100644 --- a/test/mock_pkg_resource.erl +++ b/test/mock_pkg_resource.erl @@ -16,6 +16,7 @@ mock() -> mock([]). -spec mock(Opts) -> ok when Opts :: [Option], Option :: {update, [App]} + | {cache_dir, string()} | {default_vsn, Vsn} | {override_vsn, [{App, Vsn}]} | {not_in_index, [{App, Vsn}]} @@ -83,7 +84,8 @@ mock_download(Opts) -> [kernel, stdlib] ++ [element(1,D) || D <- AppDeps] ), rebar_test_utils:create_config(Dir, [{deps, AppDeps}]), - Tarball = filename:join([Dir, App++"-"++binary_to_list(Vsn)++".tar"]), + TarApp = App++"-"++binary_to_list(Vsn)++".tar", + Tarball = filename:join([Dir, TarApp]), Contents = filename:join([Dir, "contents.tar.gz"]), Files = all_files(rebar_app_info:dir(AppInfo)), ok = erl_tar:create(Contents, @@ -92,8 +94,11 @@ mock_download(Opts) -> ok = erl_tar:create(Tarball, [{"contents.tar.gz", Contents}], []), - [file:delete(F) || F <- Files], - {tarball, Tarball} + Cache = proplists:get_value(cache_dir, Opts, filename:join(Dir,"cache")), + Cached = filename:join([Cache, TarApp]), + filelib:ensure_dir(Cached), + rebar_file_utils:mv(Tarball, Cached), + {ok, true} end). %% @doc On top of the pkg resource mocking, we need to mock the package -- cgit v1.1