Skip to content

Commit

Permalink
Cleanup warnings generated in new Elixir versions
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewDryga committed Jan 26, 2020
1 parent f096716 commit c3f1762
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lib/sage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ defmodule Sage do
Ecto must be included as application dependency.
"""
@since "0.3.3"
@doc since: "0.3.3"
@spec transaction(sage :: t(), repo :: module(), opts :: any()) ::
{:ok, result :: any(), effects :: effects()} | {:error, any()}
def transaction(%Sage{} = sage, repo, opts \\ []) do
Expand Down
44 changes: 22 additions & 22 deletions lib/sage/executor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -158,37 +158,37 @@ defmodule Sage.Executor do
end

defp apply_transaction_fun(name, {mod, fun, args} = mfa, effects_so_far, opts) do
apply(mod, fun, [effects_so_far, opts | args])
else
{:ok, effect} ->
{:ok, effect}
case apply(mod, fun, [effects_so_far, opts | args]) do
{:ok, effect} ->
{:ok, effect}

{:error, reason} ->
{:error, reason}
{:error, reason} ->
{:error, reason}

{:abort, reason} ->
{:abort, reason}
{:abort, reason} ->
{:abort, reason}

other ->
{:raise,
{%Sage.MalformedTransactionReturnError{stage: name, transaction: mfa, return: other}, System.stacktrace()}}
other ->
{:raise,
{%Sage.MalformedTransactionReturnError{stage: name, transaction: mfa, return: other}, System.stacktrace()}}
end
end

defp apply_transaction_fun(name, fun, effects_so_far, opts) do
apply(fun, [effects_so_far, opts])
else
{:ok, effect} ->
{:ok, effect}
case apply(fun, [effects_so_far, opts]) do
{:ok, effect} ->
{:ok, effect}

{:error, reason} ->
{:error, reason}
{:error, reason} ->
{:error, reason}

{:abort, reason} ->
{:abort, reason}
{:abort, reason} ->
{:abort, reason}

other ->
{:raise,
{%Sage.MalformedTransactionReturnError{stage: name, transaction: fun, return: other}, System.stacktrace()}}
other ->
{:raise,
{%Sage.MalformedTransactionReturnError{stage: name, transaction: fun, return: other}, System.stacktrace()}}
end
end

defp handle_transaction_result({:start_compensations, state}), do: {:start_compensations, state}
Expand Down
2 changes: 1 addition & 1 deletion lib/sage/inspect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defimpl Inspect, for: Sage do
def inspect(sage, opts) do
list = to_list(sage)
left = concat(["#Sage", format_compensation_error_handler(sage.on_compensation_error), "<"])
surround_many(left, list, ">", opts, fn str, _ -> str end)
container_doc(left, list, ">", opts, fn str, _ -> str end)
end

defp to_list(sage) do
Expand Down
2 changes: 1 addition & 1 deletion test/sage/executor/retries_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ defmodule Sage.Executor.RetriesTest do
retry? = retry_with_backoff?(count, opts)
stop = System.monotonic_time()
assert retry?
div(System.convert_time_unit(stop - start, :native, :micro_seconds), 100) / 10
div(System.convert_time_unit(stop - start, :native, :microsecond), 100) / 10
end
end
4 changes: 2 additions & 2 deletions test/sage/executor_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -853,13 +853,13 @@ defmodule Sage.ExecutorTest do
for step <- [:step1, :step2, :step3, :step4, :step5] do
assert_receive {^step, :start_transaction, _tracing_state}
assert_receive {^step, :finish_transaction, time_taken, _tracing_state}
assert div(System.convert_time_unit(time_taken, :native, :micro_seconds), 100) / 10 > 0.9
assert div(System.convert_time_unit(time_taken, :native, :microsecond), 100) / 10 > 0.9
end

for step <- [:step1, :step2, :step3, :step4, :step5] do
assert_receive {^step, :start_compensation, _tracing_state}
assert_receive {^step, :finish_compensation, time_taken, _tracing_state}
assert div(System.convert_time_unit(time_taken, :native, :micro_seconds), 100) / 10 > 0.9
assert div(System.convert_time_unit(time_taken, :native, :microsecond), 100) / 10 > 0.9
end
end
end
Expand Down

0 comments on commit c3f1762

Please sign in to comment.