Skip to content

Commit

Permalink
Add test for meck:expect on file module
Browse files Browse the repository at this point in the history
  • Loading branch information
beapirate committed Aug 11, 2011
1 parent 2e82eae commit ff4dc31
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/meck_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,23 @@ passthrough_bif_test() ->
?assertEqual(ok, meck:new(file, [unstick, passthrough])),
?assertEqual(ok, meck:unload(file)).

passthrough_file_bif_test_() ->
NeverExists = "/proc/0", %% 0 is invalid
AlwaysExists = "/proc/1", %% 1 is init
?assertEqual({error, enoent}, file:read_file_info(NeverExists)),
?assertMatch({ok, _}, file:read_file_info(AlwaysExists)),
{ok, ExistsInfo} = file:read_file_info(AlwaysExists),
{setup,local,
fun() -> ok = meck:new(file, [unstick, passthrough]) end,
fun(_) -> ok = meck:unload(file) end,
?_test(begin
?assertEqual(ok, meck:expect(file, read_file_info, fun
(Path) when Path =:= NeverExists -> {ok, no_info};
(Path) when Path =:= AlwaysExists -> meck:passthrough([Path]) end)),
?assertEqual({ok, no_info}, file:read_file_info(NeverExists)),
?assertEqual({ok, ExistsInfo}, file:read_file_info(AlwaysExists))
end)}.

cover_test() ->
{ok, _} = cover:compile("../test/meck_test_module.erl"),
a = meck_test_module:a(),
Expand Down

0 comments on commit ff4dc31

Please sign in to comment.