|
| 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