Created
July 26, 2018 20:48
-
-
Save oltarasenko/09cbec0c74a07155de18ae606b1fb5e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"Multiline for long messages", {timeout, 190 ,fun() -> | |
meck:expect(gen_tcp, recv, fun(_, _, _) -> {ok, <<"+OK POP3 ready">>} end), | |
Opts = [{addr, "pop.gmail.com"}, {port, 995}], | |
{ok, Connection} = epop_client:connect("test@example.com", "foo", Opts, 1000), | |
Chunk = << <<"X">> || X <- lists:seq(1, 10 * 1000) >>, | |
Msgs = [{ok, <<"+OK Some">>}] ++ [{ok, Chunk} || _X <- lists:seq(1, 1 * 100)] ++ [{ok, <<"\r\n.\r\n">>}], | |
?debugMsg("List generated"), | |
Loop = meck:loop(Msgs), | |
meck:expect(gen_tcp, recv, 3, Loop), | |
FullMsg = lists:foldl( | |
fun({ok, Msg}, Acc) -> <<Acc/binary, Msg/binary>> end, | |
<<>>, Msgs | |
), | |
<<"+OK ", ExpectedMsg/binary>> = FullMsg, | |
?debugFmt("ExpectedMsg size: ~p", [byte_size(ExpectedMsg)]), | |
{Time, _} = timer:tc(fun() -> epop_client:retrieve(Connection, <<"1">>) end), | |
% ?debugFmt("Call time large email: ~p", [Time]) | |
% Entire processing time should not take more then 5 seconds | |
?debugFmt("Time: ~p", [Time]), | |
?assert(Time < 5 * 1000 * 1000) | |
end}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment