From 1d074cbd3912be49727e04e6370723beedffd630 Mon Sep 17 00:00:00 2001 From: Oleksii Sholik Date: Mon, 8 Apr 2024 15:46:39 +0300 Subject: [PATCH] Fix WsServerTest --- .../test/electric/satellite/ws_server_test.exs | 16 +++++++++++++--- .../electric/test/support/setup_helpers.ex | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/components/electric/test/electric/satellite/ws_server_test.exs b/components/electric/test/electric/satellite/ws_server_test.exs index 63009258c4..2a02aa2a17 100644 --- a/components/electric/test/electric/satellite/ws_server_test.exs +++ b/components/electric/test/electric/satellite/ws_server_test.exs @@ -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 @@ -44,12 +51,13 @@ 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} @@ -57,7 +65,9 @@ defmodule Electric.Satellite.WebsocketServerTest do 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([ @@ -83,7 +93,7 @@ defmodule Electric.Satellite.WebsocketServerTest do stream_transactions: fn _, _, _ -> [] end } ]) do - {:ok, %{}} + %{} end # make sure server is cleaning up connections diff --git a/components/electric/test/support/setup_helpers.ex b/components/electric/test/support/setup_helpers.ex index ac73ce7b2a..932daaed5b 100644 --- a/components/electric/test/support/setup_helpers.ex +++ b/components/electric/test/support/setup_helpers.ex @@ -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!(