Skip to content

Commit

Permalink
fix: remove Realtime.Replication tests related to db retry
Browse files Browse the repository at this point in the history
  • Loading branch information
w3b6x9 committed Feb 10, 2021
1 parent 8bdfb96 commit 790af3f
Showing 1 changed file with 0 additions and 79 deletions.
79 changes: 0 additions & 79 deletions server/test/realtime/replication_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -71,83 +71,4 @@ defmodule Realtime.ReplicationTest do
types: %{}
}}
end

test "Realtime.Replication.handle_info/2 :: :EXIT when adapter conn successful" do
with_mock Realtime.Adapters.Postgres.EpgsqlImplementation,
init: fn _ ->
{:ok, "epgsqpl_pid"}
end do
state = %{@test_state | conn_retry_delays: [0, 1023, 1999]}

assert {:noreply,
%State{
config: @test_config,
connection: "epgsqpl_pid",
conn_retry_delays: [],
subscribers: [],
transaction: nil,
relations: %{},
types: %{}
}} = Realtime.Replication.handle_info({:EXIT, nil, nil}, state)
end
end

test "Realtime.Replication.handle_info/2 :: :EXIT when adapter conn fails" do
with_mock Realtime.Adapters.Postgres.EpgsqlImplementation,
init: fn _ ->
{:error, {:error, :econnrefused}}
end do
state = %{@test_state | conn_retry_delays: [0, 1023, 1999]}

assert {:noreply,
%State{
config: @test_config,
connection: nil,
conn_retry_delays: [1023, 1999],
subscribers: [],
transaction: nil,
relations: %{},
types: %{}
}} = Realtime.Replication.handle_info({:EXIT, nil, nil}, state)
end
end

test "Realtime.Replication.get_retry_delay/1 when conn_retry_delays is empty" do
state = %State{
conn_retry_delays: [],
config: [
conn_retry_initial_delay: 300,
conn_retry_maximum_delay: 180_000,
conn_retry_jitter: 0.2
]
}

{delay, %State{conn_retry_delays: delays}} = Realtime.Replication.get_retry_delay(state)

assert delay == 0
assert is_list(delays)
refute Enum.empty?(delays)
assert Enum.all?(delays, &(is_integer(&1) and &1 > 0))
end

test "Realtime.Replication.get_retry_delay/1 when conn_retry_delays is not empty" do
state = %State{
conn_retry_delays: [489, 1011, 1996, 4023]
}

{delay, %State{conn_retry_delays: delays}} = Realtime.Replication.get_retry_delay(state)

assert delay == 489
assert delays == [1011, 1996, 4023]
end

test "Realtime.Replication.reset_retry_delay/1" do
state = %State{
conn_retry_delays: [198, 403, 781]
}

%State{conn_retry_delays: delays} = Realtime.Replication.reset_retry_delay(state)

assert delays == []
end
end

0 comments on commit 790af3f

Please sign in to comment.