Skip to content

Commit fed35ec

Browse files
committed
fix: format runtime_integration_test.exs
1 parent bf02ce9 commit fed35ec

File tree

1 file changed

+39
-40
lines changed

1 file changed

+39
-40
lines changed

test/phoenix/react_server/runtime_integration_test.exs

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -60,51 +60,50 @@ defmodule Phoenix.ReactServer.RuntimeIntegrationTest do
6060
# Test passes - runtime is running
6161
:ok
6262
else
63-
64-
# Try multiple times to find an available port
65-
{_test_port, pid} =
66-
Enum.reduce_while(1..5, nil, fn _attempt, _acc ->
67-
test_port = 15_225 + :rand.uniform(1000)
68-
69-
Application.put_env(:phoenix_react_server, Bun,
70-
cmd: System.find_executable("bun"),
71-
port: test_port,
72-
env: :dev,
73-
cd: File.cwd!()
74-
)
75-
76-
# Start the runtime without name registration
77-
case GenServer.start_link(Bun, component_base: "test/fixtures", render_timeout: 5000) do
78-
{:ok, pid} ->
79-
# Give it time to start
80-
Process.sleep(2000)
81-
82-
if Process.alive?(pid) do
83-
{:halt, {test_port, pid}}
84-
else
85-
# Process died, try another port
63+
# Try multiple times to find an available port
64+
{_test_port, pid} =
65+
Enum.reduce_while(1..5, nil, fn _attempt, _acc ->
66+
test_port = 15_225 + :rand.uniform(1000)
67+
68+
Application.put_env(:phoenix_react_server, Bun,
69+
cmd: System.find_executable("bun"),
70+
port: test_port,
71+
env: :dev,
72+
cd: File.cwd!()
73+
)
74+
75+
# Start the runtime without name registration
76+
case GenServer.start_link(Bun, component_base: "test/fixtures", render_timeout: 5000) do
77+
{:ok, pid} ->
78+
# Give it time to start
79+
Process.sleep(2000)
80+
81+
if Process.alive?(pid) do
82+
{:halt, {test_port, pid}}
83+
else
84+
# Process died, try another port
85+
{:cont, nil}
86+
end
87+
88+
{:error, _reason} ->
89+
# Failed to start, try another port
8690
{:cont, nil}
87-
end
91+
end
92+
end)
8893

89-
{:error, _reason} ->
90-
# Failed to start, try another port
91-
{:cont, nil}
92-
end
93-
end)
94+
# If we couldn't find a working port, fail the test
95+
if pid == nil do
96+
flunk("Could not start Bun runtime after 5 attempts")
97+
end
9498

95-
# If we couldn't find a working port, fail the test
96-
if pid == nil do
97-
flunk("Could not start Bun runtime after 5 attempts")
98-
end
99-
100-
# Verify it's running
101-
assert Process.alive?(pid)
99+
# Verify it's running
100+
assert Process.alive?(pid)
102101

103-
# Stop the runtime
104-
GenServer.stop(pid, :normal)
102+
# Stop the runtime
103+
GenServer.stop(pid, :normal)
105104

106-
# Verify it's stopped
107-
refute Process.alive?(pid)
105+
# Verify it's stopped
106+
refute Process.alive?(pid)
108107
end
109108
end
110109
end

0 commit comments

Comments
 (0)