Skip to content

Commit

Permalink
Add test for connecting to a hostname (Nordix#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjosv authored Jun 13, 2020
1 parent 8b49f4d commit 68120d6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/eredis_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
connect_test() ->
?assertMatch({ok, _}, eredis:start_link()),
?assertMatch({ok, _}, eredis:start_link("127.0.0.1", ?PORT)),
?assertMatch({ok, _}, eredis:start_link("localhost", ?PORT)),
?assertMatch({ok, _}, eredis:start_link("localhost", ?PORT, [{database, 0},
?assertMatch({ok, _}, eredis:start_link("127.0.0.1", ?PORT, [{database, 0},
{password, ""},
{reconnect_sleep, 100},
{connect_timeout, 5000},
{socket_options, [{keepalive, true}]}
])).

connect_hostname_test() ->
Res = eredis:start_link(net_adm:localhost(), ?PORT, [{reconnect_sleep, no_reconnect}]),
?assertMatch({ok, _}, Res),
{ok, C} = Res,
?assertMatch(ok, eredis:stop(C)).

connect_local_test() ->
process_flag(trap_exit, true),
eredis:start_link({local, "/var/run/redis.sock"}, 0, [{reconnect_sleep, no_reconnect}]),
Expand Down Expand Up @@ -252,6 +257,10 @@ tcp_closed_test() ->
?assertMatch({ok, _}, eredis:q(C, ["DEL", foo], 5000)),
?assertMatch(ok, eredis:stop(C)).

connect_no_reconnect_test() ->
C = c_no_reconnect(),
?assertMatch(ok, eredis:stop(C)).

tcp_closed_no_reconnect_test() ->
C = c_no_reconnect(),
tcp_closed_rig(C).
Expand Down

0 comments on commit 68120d6

Please sign in to comment.