Skip to content

Commit 3938d29

Browse files
committed
refactor: enhance test readability by removing unnecessary blank lines in flow limits tests
1 parent efe65a7 commit 3938d29

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

test/agent_forge/flow_limits_test.exs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,49 @@
11
defmodule AgentForge.FlowLimitsTest do
22
use ExUnit.Case
3-
3+
44
alias AgentForge.Flow
55
alias AgentForge.Signal
6-
6+
77
describe "process_with_limits/4" do
88
test "processes a simple flow without timeout" do
99
signal = Signal.new(:test, "data")
1010
handler = fn sig, state -> {{:emit, Signal.new(:echo, sig.data)}, state} end
11-
11+
1212
{:ok, result, state} = Flow.process_with_limits([handler], signal, %{})
13-
13+
1414
assert result.type == :echo
1515
assert result.data == "data"
1616
assert state == %{}
1717
end
18-
18+
1919
test "enforces timeout for infinite loops" do
2020
signal = Signal.new(:start, "data")
21-
21+
2222
# Create an infinite loop handler that always emits the same signal
2323
infinite_loop = fn signal, state ->
24-
Process.sleep(100) # Add a small delay to ensure timeout works
24+
# Add a small delay to ensure timeout works
25+
Process.sleep(100)
2526
{{:emit, signal}, state}
2627
end
27-
28+
2829
# Should terminate after timeout
2930
result = Flow.process_with_limits([infinite_loop], signal, %{}, timeout_ms: 300)
30-
31+
3132
# Verify we got an error
3233
assert {:error, error_msg, final_state} = result
3334
assert error_msg =~ "timed out"
34-
assert final_state == %{} # State should be preserved
35+
# State should be preserved
36+
assert final_state == %{}
3537
end
36-
38+
3739
test "handles normal termination" do
3840
signal = Signal.new(:test, "data")
39-
41+
4042
# This handler will terminate after 3 steps
4143
counter_handler = fn signal, state ->
4244
counter = Map.get(state, :counter, 0) + 1
4345
new_state = Map.put(state, :counter, counter)
44-
46+
4547
if counter >= 3 do
4648
# Terminate after 3 steps
4749
{{:halt, "done after #{counter} steps"}, new_state}
@@ -50,14 +52,14 @@ defmodule AgentForge.FlowLimitsTest do
5052
{{:emit, Signal.new(:"step_#{counter}", signal.data)}, new_state}
5153
end
5254
end
53-
55+
5456
# Should complete normally
5557
{:ok, result, final_state} = Flow.process_with_limits([counter_handler], signal, %{})
56-
58+
5759
assert result == "done after 3 steps"
5860
assert final_state.counter == 3
5961
end
60-
62+
6163
test "handles multiple signal emissions" do
6264
signal = Signal.new(:test, "data")
6365

@@ -68,15 +70,17 @@ defmodule AgentForge.FlowLimitsTest do
6870
Signal.new(:second, "two"),
6971
Signal.new(:third, "three")
7072
]
73+
7174
{{:emit_many, signals}, state}
7275
end
7376

7477
{:ok, result, _state} = Flow.process_with_limits([multi_emit], signal, %{})
7578

76-
assert result.type == :third # Should continue with the last signal
79+
# Should continue with the last signal
80+
assert result.type == :third
7781
assert result.data == "three"
7882
end
79-
83+
8084
test "handles errors in handlers" do
8185
signal = Signal.new(:test, "data")
8286

@@ -89,9 +93,10 @@ defmodule AgentForge.FlowLimitsTest do
8993
{:error, error_msg, state} = Flow.process_with_limits([error_handler], signal, %{})
9094

9195
assert error_msg == "Handler error"
92-
assert state == %{} # State should be preserved
96+
# State should be preserved
97+
assert state == %{}
9398
end
94-
99+
95100
test "respects handler skip response" do
96101
signal = Signal.new(:test, "data")
97102

0 commit comments

Comments
 (0)