Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove unneeded match?/2 calls and instead use = operator #478

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions test/integration/proxy_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Supavisor.Integration.ProxyTest do
use Supavisor.DataCase, async: true
use Supavisor.DataCase, async: false

require Logger

Expand Down Expand Up @@ -32,7 +32,7 @@
%{proxy: proxy, origin: origin, user: db_conf[:username]}
end

test "prepared statement", %{proxy: proxy} do

Check failure on line 35 in test/integration/proxy_test.exs

View workflow job for this annotation

GitHub Actions / Run tests

test prepared statement (Supavisor.Integration.ProxyTest)
prepare_sql =
"PREPARE tenant (text) AS SELECT id, external_id FROM _supavisor.tenants WHERE external_id = $1;"

Expand Down Expand Up @@ -66,14 +66,14 @@
}} = parse_uri(url) |> single_connection()
end

test "insert", %{proxy: proxy, origin: origin} do

Check failure on line 69 in test/integration/proxy_test.exs

View workflow job for this annotation

GitHub Actions / Run tests

test insert (Supavisor.Integration.ProxyTest)
P.query!(proxy, "insert into public.test (details) values ('test_insert')", [])

assert %P.Result{num_rows: 1} =
P.query!(origin, "select * from public.test where details = 'test_insert'", [])
end

test "query via another node", %{proxy: proxy, user: user} do

Check failure on line 76 in test/integration/proxy_test.exs

View workflow job for this annotation

GitHub Actions / Run tests

test query via another node (Supavisor.Integration.ProxyTest)
{:ok, _pid, node2} = Cluster.start_node()

sup =
Expand Down Expand Up @@ -123,14 +123,14 @@
)
end

test "select", %{proxy: proxy, origin: origin} do

Check failure on line 126 in test/integration/proxy_test.exs

View workflow job for this annotation

GitHub Actions / Run tests

test select (Supavisor.Integration.ProxyTest)
P.query!(origin, "insert into public.test (details) values ('test_select')", [])

assert %P.Result{num_rows: 1} =
P.query!(proxy, "select * from public.test where details = 'test_select'", [])
end

test "update", %{proxy: proxy, origin: origin} do

Check failure on line 133 in test/integration/proxy_test.exs

View workflow job for this annotation

GitHub Actions / Run tests

test update (Supavisor.Integration.ProxyTest)
P.query!(origin, "insert into public.test (details) values ('test_update')", [])

P.query!(
Expand All @@ -147,7 +147,7 @@
)
end

test "delete", %{proxy: proxy, origin: origin} do

Check failure on line 150 in test/integration/proxy_test.exs

View workflow job for this annotation

GitHub Actions / Run tests

test delete (Supavisor.Integration.ProxyTest)
P.query!(origin, "insert into public.test (details) values ('test_delete')", [])
P.query!(proxy, "delete from public.test where details = 'test_delete'", [])

Expand Down Expand Up @@ -195,7 +195,7 @@
[{~c"x-app-version", Application.spec(:supavisor, :vsn)}], []}}
end

test "checks that client_handler is idle and db_pid is nil for transaction mode" do

Check failure on line 198 in test/integration/proxy_test.exs

View workflow job for this annotation

GitHub Actions / Run tests

test checks that client_handler is idle and db_pid is nil for transaction mode (Supavisor.Integration.ProxyTest)
db_conf = Application.get_env(:supavisor, Repo)

url =
Expand Down Expand Up @@ -242,7 +242,7 @@
}} = single_connection(connection_opts)
end

test "change role password", %{origin: origin} do

Check failure on line 245 in test/integration/proxy_test.exs

View workflow job for this annotation

GitHub Actions / Run tests

test change role password (Supavisor.Integration.ProxyTest)
Process.flag(:trap_exit, true)
db_conf = Application.get_env(:supavisor, Repo)

Expand Down Expand Up @@ -361,20 +361,17 @@
id = {{:single, @tenant}, db_conf[:username], :session, db_conf[:database], nil}
[{client_pid, _}] = Registry.lookup(Supavisor.Registry.TenantClients, id)

assert match?({_, %{active_count: 1}}, :sys.get_state(client_pid))
assert {_, %{active_count: 1}} = :sys.get_state(client_pid)

Enum.each(0..200, fn _ ->
P.SimpleConnection.call(pid, {:query, "select 1;"})
end)

assert match?(
[
%Postgrex.Result{
command: :select
}
],
P.SimpleConnection.call(pid, {:query, "select 1;"})
)
assert [
%Postgrex.Result{
command: :select
}
] = P.SimpleConnection.call(pid, {:query, "select 1;"})
end

defp single_connection(db_conf, c_port \\ nil) when is_list(db_conf) do
Expand Down
Loading