diff options
author | Sergei Elin <s.elin@xpay.by> | 2022-09-23 01:10:45 +0300 |
---|---|---|
committer | Jens Geyer <Jens-G@users.noreply.github.com> | 2022-09-23 08:43:01 +0200 |
commit | 4748f3ba4fad4900c5fdfcbfc3bb10709d714d97 (patch) | |
tree | 8ae506de2014ed54dc8eabec0e432e32d4be2a13 /lib | |
parent | aebdb412d361c9efaec399c61d4c3d5e39a80d5f (diff) | |
download | thrift-4748f3ba4fad4900c5fdfcbfc3bb10709d714d97.tar.gz |
THRIFT-5636: Fix tests for new thrift_socket_transport:read/2
Diffstat (limited to 'lib')
-rw-r--r-- | lib/erl/test/test_thrift_socket_transport.erl | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/erl/test/test_thrift_socket_transport.erl b/lib/erl/test/test_thrift_socket_transport.erl index 5bc0f246d..757c6d993 100644 --- a/lib/erl/test/test_thrift_socket_transport.erl +++ b/lib/erl/test/test_thrift_socket_transport.erl @@ -51,7 +51,12 @@ read_test_() -> {setup, fun() -> meck:new(gen_tcp, [unstick, passthrough]), - meck:expect(gen_tcp, recv, fun(Bin, 0, _) -> {ok, Bin} end) + meck:expect(gen_tcp, recv, fun(Bin, 0, _) -> + case Bin of + <<"empty">> -> {error, timeout}; + _ -> {ok, Bin} + end end), + meck:expect(gen_tcp, close, fun(_) -> ok end) end, fun(_) -> meck:unload(gen_tcp) end, [ @@ -60,8 +65,8 @@ read_test_() -> read({t_socket, <<>>, 60000, []}, 0) )}, {"read 1 byte from empty socket", ?_assertMatch( - {_, {ok, <<>>}}, - read({t_socket, <<>>, 60000, []}, 1) + {_, {error, timeout}}, + read({t_socket, <<"empty">>, 60000, []}, 1) )}, {"read zero bytes from nonempty socket", ?_assertMatch( {{t_socket, _, _, _}, {ok, <<>>}}, @@ -72,8 +77,8 @@ read_test_() -> read({t_socket, <<"hallo world">>, 60000, []}, 1) )}, {"read a zillion bytes from nonempty socket", ?_assertMatch( - {{t_socket, _, _, <<>>}, {ok, <<"hallo world">>}}, - read({t_socket, <<"hallo world">>, 60000, []}, 65536) + {{t_socket, _, _, <<"ld">>}, {ok, <<"hallo world world world world wor">>}}, + read({t_socket, <<"hallo world world world world world">>, 60000, []}, 33) )}, {"read 1 byte from previously buffered socket", ?_assertMatch( {{t_socket, _, _, <<"allo">>}, {ok, <<"h">>}}, @@ -84,8 +89,8 @@ read_test_() -> read({t_socket, <<" world">>, 60000, <<"hallo">>}, 6) )}, {"read a zillion bytes from previously buffered socket", ?_assertMatch( - {{t_socket, _, _, <<>>}, {ok, <<"hallo world">>}}, - read({t_socket, <<" world">>, 60000, <<"hallo">>}, 65536) + {{t_socket, _, _, <<"ld">>}, {ok, <<"hallo world world world world wor">>}}, + read({t_socket, <<" world">>, 60000, <<"hallo">>}, 33) )} ] }. @@ -196,4 +201,4 @@ close_test_() -> close({t_socket, a_fake_socket, 60000, []}) )} ] - }.
\ No newline at end of file + }. |