forked from basho/sidejob
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request basho#1 from zotonic/develop
Zotonic changes to side job
- Loading branch information
Showing
3 changed files
with
65 additions
and
19 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-module(supervisor_test). | ||
-export([fail_to_start_link/0]). | ||
-include_lib("eunit/include/eunit.hrl"). | ||
|
||
-define(RESOURCE, supervisor_test_resource). | ||
|
||
% Setup a sidejob resource and start a child that links to the parent but doesn't return {ok, Pid}. | ||
% The supervisor should not shut down. | ||
spurious_exit_test() -> | ||
{ok, _} = application:ensure_all_started(sidejob), | ||
{ok, _} = sidejob:new_resource(?RESOURCE, sidejob_supervisor, 5, 1), | ||
{WorkerReg} = ?RESOURCE:workers(), | ||
WorkerPid = whereis(WorkerReg), | ||
?assert(is_process_alive(WorkerPid)), | ||
{ok, undefined} = sidejob_supervisor:start_child(?RESOURCE, ?MODULE, fail_to_start_link, []), | ||
sidejob_supervisor:which_children(?RESOURCE), % wait for sidejob_supervisor to process the EXIT | ||
?assert(is_process_alive(WorkerPid)). | ||
|
||
fail_to_start_link() -> | ||
spawn_link(fun () -> ok end), | ||
ignore. |