-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
José Valim
committed
Jun 28, 2019
1 parent
c0ef041
commit 1bc0b25
Showing
4 changed files
with
52 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
defmodule Phoenix.Tracker.ShardTest do | ||
use ExUnit.Case, async: true | ||
@opts [pubsub_server: nil, name: nil] | ||
|
||
test "validates down_period" do | ||
opts = Keyword.merge(@opts, [down_period: 1]) | ||
assert Phoenix.Tracker.Shard.init([nil, nil, opts]) == | ||
{:error, "down_period must be at least twice as large as the broadcast_period"} | ||
end | ||
|
||
test "validates permdown_period" do | ||
opts = Keyword.merge(@opts, [permdown_period: 1_200_00, down_period: 1_200_000]) | ||
assert Phoenix.Tracker.Shard.init([nil, nil, opts]) == | ||
{:error, "permdown_period must be at least larger than the down_period"} | ||
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 |
---|---|---|
|
@@ -409,5 +409,4 @@ defmodule Phoenix.Tracker.StateTest do | |
end) | ||
end) | ||
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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
defmodule Phoenix.Tracker.ShardTest do | ||
defmodule Phoenix.TrackerTest do | ||
use ExUnit.Case, async: true | ||
@opts [pubsub_server: nil, name: nil] | ||
|
||
test "validates down_period" do | ||
opts = Keyword.merge(@opts, [down_period: 1]) | ||
assert Phoenix.Tracker.Shard.init([nil, nil, opts]) == | ||
{:error, "down_period must be at least twice as large as the broadcast_period"} | ||
defmodule MyTracker do | ||
use Phoenix.Tracker | ||
def init(state), do: {:ok, state} | ||
def handle_diff(_diff, state), do: {:ok, state} | ||
end | ||
|
||
test "validates permdown_period" do | ||
opts = Keyword.merge(@opts, [permdown_period: 1_200_00, down_period: 1_200_000]) | ||
assert Phoenix.Tracker.Shard.init([nil, nil, opts]) == | ||
{:error, "permdown_period must be at least larger than the down_period"} | ||
test "generates child spec" do | ||
assert MyTracker.child_spec([]) == %{ | ||
id: Phoenix.TrackerTest.MyTracker, | ||
start: {Phoenix.TrackerTest.MyTracker, :start_link, [[]]}, | ||
type: :supervisor | ||
} | ||
end | ||
end |