Skip to content

Commit

Permalink
Fix WsServerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
alco committed Apr 10, 2024
1 parent 9a5a1cd commit 1d074cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions components/electric/test/electric/satellite/ws_server_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ defmodule Electric.Satellite.WebsocketServerTest do

import Mock

setup_with_mocks([
{Electric.Replication.Postgres.Client, [:passthrough],
with_pool: fn _, _ -> :ok end, pooled_query!: fn _, _, _ -> :ok end}
]) do
%{}
end

setup ctx do
ctx =
ctx
Expand All @@ -44,20 +51,23 @@ defmodule Electric.Satellite.WebsocketServerTest do
)
|> Map.put_new(:allowed_unacked_txs, 30)

connector_config = [origin: "test-origin", connection: []]
port = 55133

plug =
{Electric.Plug.SatelliteWebsocketPlug,
auth_provider: Auth.provider(),
connector_config: [origin: "fake_origin"],
connector_config: connector_config,
subscription_data_fun: ctx.subscription_data_fun,
allowed_unacked_txs: ctx.allowed_unacked_txs}

start_link_supervised!({Bandit, port: port, plug: plug})

server_id = Electric.instance_id()

{:ok, port: port, server_id: server_id}
start_link_supervised!({Electric.Satellite.ClientReconnectionInfo, connector_config})

%{port: port, server_id: server_id}
end

setup_with_mocks([
Expand All @@ -83,7 +93,7 @@ defmodule Electric.Satellite.WebsocketServerTest do
stream_transactions: fn _, _, _ -> [] end
}
]) do
{:ok, %{}}
%{}
end

# make sure server is cleaning up connections
Expand Down
2 changes: 1 addition & 1 deletion components/electric/test/support/setup_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule ElectricTest.SetupHelpers do
Starts SchemaCache process with a given origin, and
immediately fills it from given SQL.
"""
def start_schema_cache(origin \\ "fake_origin", migrations) do
def start_schema_cache(origin \\ "test-origin", migrations) do
backend = Electric.Postgres.MockSchemaLoader.start_link(migrations: migrations)

start_supervised!(
Expand Down

0 comments on commit 1d074cb

Please sign in to comment.