Skip to content

Commit

Permalink
Refactor parcels_test.exs
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmi committed Jan 11, 2024
1 parent 809ce08 commit 2108e70
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- restart strategy
- renamer can be just a simple module
- source and sink behaviours
- tick source with timeout
11 changes: 4 additions & 7 deletions test/examples/parcels/parcels_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ defmodule Strom.Examples.ParcelsTest do
{[bad], memo}
else
memo = Map.put(memo, order_number, {amount - 1, order_occurred_at})

{[], memo}
end
end
Expand All @@ -184,11 +183,6 @@ defmodule Strom.Examples.ParcelsTest do
end

def topology(_opts) do
partitions = %{
threshold_exceeded: &(&1[:type] == "THRESHOLD_EXCEEDED"),
all_parcels_shipped: &(&1[:type] == "ALL_PARCELS_SHIPPED")
}

[
source(:orders, %ReadLines{path: "test/examples/parcels/orders.csv"}),
transform([:orders], &__MODULE__.build_order/1),
Expand All @@ -197,7 +191,10 @@ defmodule Strom.Examples.ParcelsTest do
mix([:orders, :parcels], :mixed),
transform([:mixed], &ParcelsFlow.force_order/2, %{}),
transform([:mixed], &ParcelsFlow.decide/2, %{}),
split(:mixed, partitions),
split(:mixed, %{
threshold_exceeded: &(&1[:type] == "THRESHOLD_EXCEEDED"),
all_parcels_shipped: &(&1[:type] == "ALL_PARCELS_SHIPPED")
}),
transform([:threshold_exceeded, :all_parcels_shipped], &__MODULE__.to_string/1),
sink(:threshold_exceeded, %WriteLines{
path: "test/examples/parcels/threshold_exceeded.csv"
Expand Down

0 comments on commit 2108e70

Please sign in to comment.