Skip to content

Commit b28fec2

Browse files
committed
test: add comprehensive examples tests for order processing and validation
1 parent 82e694f commit b28fec2

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ jobs:
5151

5252
- name: Run Tests
5353
run: mix test
54+
env:
55+
MIX_ENV: test
56+
# Ensure example tests are included
57+
INCLUDE_EXAMPLES: true
5458

5559
- name: Code Coverage
5660
run: mix coveralls.github

test/agent_forge/examples_test.exs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
defmodule AgentForge.ExamplesTest do
2+
use ExUnit.Case
3+
doctest AgentForge
4+
5+
def capture_io(fun) do
6+
ExUnit.CaptureIO.capture_io(fun)
7+
end
8+
9+
describe "data_processing.exs" do
10+
test "correctly processes orders with tax calculations" do
11+
output = capture_io(fn -> Code.eval_file("examples/data_processing.exs") end)
12+
13+
# Verify standard order processing
14+
assert output =~ ~r/Standard order processed:.*id: 1, total: 550.0/
15+
# Verify large order notification
16+
assert output =~ "[Notification] Large order received: #2 (Total: $1320.0)"
17+
# Verify another standard order
18+
assert output =~ ~r/Standard order processed:.*id: 3, total: 880.0/
19+
end
20+
end
21+
22+
describe "config_workflow.exs" do
23+
test "handles validation and age-based routing" do
24+
output = capture_io(fn -> Code.eval_file("examples/config_workflow.exs") end)
25+
26+
# Verify adult processing
27+
assert output =~ "Processing adult user: John Doe"
28+
# Verify minor processing
29+
assert output =~ "Cannot process minor: Jane Smith"
30+
# Verify validation errors
31+
assert output =~ "name is required"
32+
assert output =~ "age must be at least 0"
33+
end
34+
end
35+
36+
describe "async_workflow.exs" do
37+
test "handles async operations correctly" do
38+
output = capture_io(fn -> Code.eval_file("examples/async_workflow.exs") end)
39+
40+
# Verify workflow completion and job result
41+
assert output =~ "Workflow completed successfully"
42+
assert output =~ ~r/data: "Job completed with result: \\"Completed\\""/
43+
end
44+
end
45+
end

0 commit comments

Comments
 (0)