diff options
author | Loïc Hoguin <[email protected]> | 2019-07-24 16:22:26 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-07-24 16:22:26 +0200 |
commit | 3d1e3c9e6e779bca839b86717adb2487b4a1c2c6 (patch) | |
tree | 488db6e9ea303d8866eb2affc706d2162a9deb70 /test | |
parent | 8c6adf73d9d3fa1ebb49d4b9bd71caab1815dcb2 (diff) | |
download | gun-3d1e3c9e6e779bca839b86717adb2487b4a1c2c6.tar.gz gun-3d1e3c9e6e779bca839b86717adb2487b4a1c2c6.tar.bz2 gun-3d1e3c9e6e779bca839b86717adb2487b4a1c2c6.zip |
Add the cancel event for local/remote stream cancellation
Diffstat (limited to 'test')
-rw-r--r-- | test/event_SUITE.erl | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/test/event_SUITE.erl b/test/event_SUITE.erl index ace509a..d043a11 100644 --- a/test/event_SUITE.erl +++ b/test/event_SUITE.erl @@ -35,7 +35,7 @@ groups() -> %% We currently do not support Websocket over HTTP/2. WsTests = [T || T <- Tests, lists:sublist(atom_to_list(T), 3) =:= "ws_"], [ - {http, [parallel], Tests -- PushTests}, + {http, [parallel], Tests -- [cancel_remote|PushTests]}, {http2, [parallel], Tests -- [protocol_changed|WsTests]} ]. @@ -629,6 +629,36 @@ do_ws_send_frame(Config, EventName) -> } = do_receive_event(EventName), gun:close(Pid). +cancel(Config) -> + doc("Confirm that the cancel event callback is called when we cancel a stream."), + {ok, Pid, _} = do_gun_open(Config), + {ok, _} = gun:await_up(Pid), + StreamRef = gun:post(Pid, "/stream", []), + gun:cancel(Pid, StreamRef), + ReplyTo = self(), + #{ + stream_ref := StreamRef, + reply_to := ReplyTo, + endpoint := local, + reason := cancel + } = do_receive_event(?FUNCTION_NAME), + gun:close(Pid). + +cancel_remote(Config) -> + doc("Confirm that the cancel event callback is called " + "when the remote endpoint cancels the stream."), + {ok, Pid, _} = do_gun_open(Config), + {ok, _} = gun:await_up(Pid), + StreamRef = gun:post(Pid, "/stream", []), + ReplyTo = self(), + #{ + stream_ref := StreamRef, + reply_to := ReplyTo, + endpoint := remote, + reason := _ + } = do_receive_event(cancel), + gun:close(Pid). + disconnect(Config) -> doc("Confirm that the disconnect event callback is called on disconnect."), {ok, OriginPid, OriginPort} = init_origin(tcp), @@ -639,7 +669,7 @@ disconnect(Config) -> exit(OriginPid, shutdown), #{ reason := closed - } = do_receive_event(disconnect), + } = do_receive_event(?FUNCTION_NAME), gun:close(Pid). terminate(Config) -> @@ -649,7 +679,7 @@ terminate(Config) -> #{ state := _, reason := shutdown - } = do_receive_event(terminate), + } = do_receive_event(?FUNCTION_NAME), ok. %% Internal. @@ -785,6 +815,10 @@ ws_send_frame_end(EventData, Pid) -> Pid ! {?FUNCTION_NAME, EventData}, Pid. +cancel(EventData, Pid) -> + Pid ! {?FUNCTION_NAME, EventData}, + Pid. + disconnect(EventData, Pid) -> Pid ! {?FUNCTION_NAME, EventData}, Pid. |