perform returns a map instead of a list

parent b2e02569
......@@ -9,10 +9,13 @@ defmodule Grengine.Conductor do
def perform do
get_performances()
|> Enum.map( fn perf ->
do_performance(perf)
|> Enum.reduce(%{}, fn perf, acc ->
{name, val} = do_performance(perf)
case name do
nil -> acc
_ -> Map.put(acc, name, val)
end
end)
|> Enum.reject( fn val -> is_nil(val) end)
end
......@@ -27,8 +30,8 @@ defmodule Grengine.Conductor do
[{_n, _l, {:performance, name}}, _pid, :undefined] = perf
values = Performance.get_values(name)
case length( Map.keys(values)) do
0 -> nil
_ -> %{name => Performance.get_values(name)}
0 -> {nil, nil}
_ -> {name, Performance.get_values(name)}
end
end
......
......@@ -24,8 +24,8 @@ defmodule ConductorTest do
test "handle single performance" do
values = Conductor.perform()
assert is_list(values)
assert length(values) == 1
assert is_map(values)
assert length(Map.keys(values)) == 1
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment