okami.mom/albedo

git clone https://git.nkp.pet/okami.mom/albedo

Aly Raffauffeat(api)!: migrate daemon and clients to protocol 361c43ca

main
1.7 KiB37 linesraw
1%% Exact exception classification cannot be asserted through HTTP: application
2%% panics and disappearing actor handles must have different failure behavior.
3-module(albedo_daemon_request_test).
4-include_lib("eunit/include/eunit.hrl").
5
6closed_actor_calls_are_unavailable_test() ->
7    lists:foreach(fun(Message) ->
8        Reason = #{module => <<"gleam/erlang/process">>,
9                   function => <<"perform_call">>, message => Message},
10        ?assertEqual({error,nil}, albedo_daemon:http_request(fun() ->
11            erlang:error(Reason)
12        end))
13    end, [<<"callee exited: ProcessDown(..., Normal)">>,
14          <<"Callee subject had no owner">>,
15          <<"callee did not send reply before timeout">>]).
16
17unrelated_errors_keep_their_reason_test() ->
18    Reasons = [#{module => <<"application">>, function => <<"perform_call">>,
19                 message => <<"callee exited: unrelated application error">>},
20               #{module => <<"gleam/erlang/process">>,
21                 function => <<"perform_call">>,
22                 message => <<"callee did not send reply before timeout: application error">>},
23               #{module => <<"gleam/erlang/process">>,
24                 function => <<"application_call">>,
25                 message => <<"callee did not send reply before timeout">>},
26               application_bug],
27    lists:foreach(fun(Reason) ->
28        ?assertException(error,Reason,albedo_daemon:http_request(fun() ->
29            erlang:error(Reason)
30        end))
31    end, Reasons),
32    ?assertException(throw,application_bug,albedo_daemon:http_request(fun() ->
33        throw(application_bug)
34    end)).
35
36ordinary_responses_pass_through_test() ->
37    ?assertEqual({ok,response}, albedo_daemon:http_request(fun() -> response end)).