Ver código fonte

Add a test for rotation failing and returning an error

pull/156/merge
Andrew Thompson 12 anos atrás
pai
commit
d613b595ba
1 arquivos alterados com 19 adições e 0 exclusões
  1. +19
    -0
      src/lager_util.erl

+ 19
- 0
src/lager_util.erl Ver arquivo

@ -565,6 +565,25 @@ rotate_file_test() ->
rotate_logfile("rotation.log", 10)
end || N <- lists:seq(0, 20)].
rotate_file_fail_test() ->
%% make sure the directory exists
?assertEqual(ok, filelib:ensure_dir("rotation/rotation.log")),
%% fix the permissions on it
os:cmd("chown -R u+rwx rotation"),
%% delete any old files
[ok = file:delete(F) || F <- filelib:wildcard("rotation/*")],
%% write a file
file:write_file("rotation/rotation.log", "hello"),
%% hose up the permissions
os:cmd("chown u-w rotation"),
?assertMatch({error, _}, rotate_logfile("rotation.log", 10)),
?assert(filelib:is_regular("rotation/rotation.log")),
os:cmd("chown u+w rotation"),
?assertMatch(ok, rotate_logfile("rotation/rotation.log", 10)),
?assert(filelib:is_regular("rotation/rotation.log.0")),
?assertEqual(false, filelib:is_regular("rotation/rotation.log")),
ok.
check_trace_test() ->
trace_filter(none),
%% match by module

Carregando…
Cancelar
Salvar