Skip to content

Commit

Permalink
More test
Browse files Browse the repository at this point in the history
  • Loading branch information
JanHenryNystrom committed Apr 2, 2016
1 parent 756c486 commit 4c40e4f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/syslog.erl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ open(Opts = #opts{type = udp}) ->
dest_port = DestPort1};
Error -> Error
catch
error:Error -> {error, Error}
Class:Error -> {error, {Class, Error}}
end;
open(Opts = #opts{type = tcp}) ->
#opts{role = Role,
Expand Down
55 changes: 53 additions & 2 deletions test/syslog_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ open_1_client_test_() ->
syslog:close(
syslog:open([tls,
{destination, {127, 0, 0, 1}},
{destination_port, 6514}]))))
{destination_port, 6514}])))),
?_test(?assertEqual({error, {exit, badarg}},
syslog:open([{opts, [{ip, none}]}])))
]}.

open_1_client_timeout_test_() ->
Expand Down Expand Up @@ -199,7 +201,21 @@ send_2_test_() ->
?_test(
?assertMatch(ok,
syslog:send(element(2, hd(ets:lookup(send_2_test, tlsc))),
#{})))
#{}))),
?_test(
?assertEqual({error, function_clause},
syslog:send(#transport{type = udp}, #{}))),
?_test(
?assertEqual({error, function_clause},
syslog:send(#transport{type = udp},
#{},
[{destination, {127, 0, 0, 1}}]))),
?_test(
?assertEqual({error, function_clause},
syslog:send(#transport{type = tcp}, #{}))),
?_test(
?assertEqual({error, function_clause},
syslog:send(#transport{type = tls}, #{})))
]}.

%%--------------------------------------------------------------------
Expand All @@ -219,6 +235,41 @@ close_1_test_() ->
syslog:close(#transport{type = tls_listen})))
].

%%--------------------------------------------------------------------
%% setopts/2
%%--------------------------------------------------------------------
setopts_2_test_() ->
[?_test(?assertEqual({error, function_clause},
syslog:setopts(#transport{type = udp}, self()))),
?_test(?assertEqual({error, function_clause},
syslog:setopts(#transport{type = tcp}, self()))),
?_test(?assertEqual({error, function_clause},
syslog:setopts(#transport{type = tls}, self())))
].

%%--------------------------------------------------------------------
%% controlling_process/2
%%--------------------------------------------------------------------
controlling_process_2_test_() ->
[?_test(?assertEqual({error, function_clause},
syslog:controlling_process(#transport{type = udp},
self()))),
?_test(?assertEqual({error, function_clause},
syslog:controlling_process(#transport{type = tcp},
self()))),
?_test(
?assertEqual({error, function_clause},
syslog:controlling_process(#transport{type = tcp_listen},
self()))),
?_test(?assertEqual({error, function_clause},
syslog:controlling_process(#transport{type = tls},
self()))),
?_test(
?assertEqual({error, function_clause},
syslog:controlling_process(#transport{type = tls_listen},
self())))
].


%% ===================================================================
%% Encode/Decode
Expand Down

0 comments on commit 4c40e4f

Please sign in to comment.