Repository: commanded/commanded (elixir)

Issue:
Router timout :infinity match error
Guard clause https://github.com/commanded/commanded/blob/master/lib/commanded/aggregates/aggregate.ex#L113-L114 prevents `:infinity` timeout

Pull request description:
allow infinity timeout
Fixes #225 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c689d44..d08592b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@
 - Generate specs and docs for Router dispatch functions only once ([#206](https://github.com/commanded/commanded/pull/206)).
 - Allow two-arity predicate function in `wait_for_event` receiving both event data and recorded event struct ([#213](https://github.com/commanded/commanded/pull/213)).
 - Make poison an optional dependency ([#215](https://github.com/commanded/commanded/pull/215)).
+- Allow `:infinity` timeout on command dispatch ([#227](https://github.com/commanded/commanded/pull/227))
 
 ### Bug fixes
 
diff --git a/lib/commanded/aggregates/aggregate.ex b/lib/commanded/aggregates/aggregate.ex
index 5f543b2..eb13a56 100644
--- a/lib/commanded/aggregates/aggregate.ex
+++ b/lib/commanded/aggregates/aggregate.ex
@@ -111,7 +111,7 @@ defmodule Commanded.Aggregates.Aggregate do
 
   """
   def execute(aggregate_module, aggregate_uuid, %ExecutionContext{} = context, timeout \\ 5_000)
-      when is_atom(aggregate_module) and is_binary(aggregate_uuid) and is_number(timeout) do
+      when is_atom(aggregate_module) and is_binary(aggregate_uuid) and is_number(timeout) or timeout == :infinity do
     GenServer.call(
       via_name(aggregate_module, aggregate_uuid),
       {:execute_command, context},


Test patch:
diff --git a/test/commands/command_timeout_test.exs b/test/commands/command_timeout_test.exs
index e02c797..35acd58 100644
--- a/test/commands/command_timeout_test.exs
+++ b/test/commands/command_timeout_test.exs
@@ -23,4 +23,12 @@ defmodule Commanded.Commands.CommandTimeoutTest do
         2_000
       )
   end
+
+  test "should accept :infinity as timeout option" do
+    :ok =
+      TimeoutRouter.dispatch(
+        %TimeoutCommand{aggregate_uuid: UUID.uuid4(), sleep_in_ms: 1},
+        :infinity
+      )
+  end
 end