diff options
| author | Fred Hebert <mononcqc@ferd.ca> | 2015-05-13 10:38:07 +0000 | 
|---|---|---|
| committer | Fred Hebert <mononcqc@ferd.ca> | 2015-05-13 10:38:07 +0000 | 
| commit | 715c4b2360ed2768cb292f1c2055b1e24f76f624 (patch) | |
| tree | 6e7e0b7605f46cff66c7f791d11cd24f5992be1e | |
| parent | 86fbaaeb08e7fc35ee87daea62be7febacd14ea9 (diff) | |
Update mock so existing tests pass
| -rw-r--r-- | test/mock_pkg_resource.erl | 11 | 
1 files 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 | 
