forked from commanded/commanded
-
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.
Remove after_start/0 and update tests and docs
- Loading branch information
Showing
10 changed files
with
65 additions
and
17 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
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
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,9 @@ | ||
defmodule Commanded.Event.AfterStartHandler do | ||
use Commanded.Event.Handler, | ||
application: Commanded.MockedApp, | ||
name: __MODULE__ | ||
|
||
def after_start(_state) do | ||
Process.send(:test, {:after_start, self()}, []) | ||
end | ||
end |
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,37 @@ | ||
defmodule Commanded.Event.HandlerAfterStartTest do | ||
use Commanded.MockEventStoreCase | ||
|
||
import Mox | ||
|
||
alias Commanded.Event.AfterStartHandler | ||
alias Commanded.EventStore.Adapters.Mock, as: MockEventStore | ||
|
||
describe "event handler `after_start/1` callback" do | ||
setup do | ||
true = Process.register(self(), :test) | ||
|
||
expect(MockEventStore, :subscribe_to, fn | ||
_event_store, :all, handler_name, handler, _subscribe_from, _opts -> | ||
assert is_binary(handler_name) | ||
|
||
{:ok, handler} | ||
end) | ||
|
||
handler = start_supervised!(AfterStartHandler) | ||
|
||
[handler: handler] | ||
end | ||
|
||
test "should be called after subscription subscribed", %{handler: handler} do | ||
refute_receive {:after_start, ^handler} | ||
|
||
send_subscribed(handler) | ||
|
||
assert_receive {:after_start, ^handler} | ||
end | ||
end | ||
|
||
defp send_subscribed(handler) do | ||
send(handler, {:subscribed, handler}) | ||
end | ||
end |
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