From e6c6ea63540d483a79cc0241510f3d642fe3bd08 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Mon, 1 Oct 2018 09:48:15 -0500 Subject: [PATCH] Test timeout override --- apps/explorer/lib/explorer/chain/import.ex | 4 +- .../test/explorer/chain/import_test.exs | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/apps/explorer/lib/explorer/chain/import.ex b/apps/explorer/lib/explorer/chain/import.ex index fc275d4c12..1e39ff79fb 100644 --- a/apps/explorer/lib/explorer/chain/import.ex +++ b/apps/explorer/lib/explorer/chain/import.ex @@ -520,9 +520,7 @@ defmodule Explorer.Chain.Import do when is_map(ecto_schema_module_to_changes_list) and is_map(options) do case ecto_schema_module_to_changes_list do %{Token => tokens_changes} -> - tokens_options = Map.fetch!(options, :tokens) - timestamps = Map.fetch!(options, :timestamps) - on_conflict = Map.fetch!(tokens_options, :on_conflict) + %{timestamps: timestamps, tokens: %{on_conflict: on_conflict}} = options Multi.run(multi, :tokens, fn _ -> insert_tokens( diff --git a/apps/explorer/test/explorer/chain/import_test.exs b/apps/explorer/test/explorer/chain/import_test.exs index fc8f637984..c626d638b4 100644 --- a/apps/explorer/test/explorer/chain/import_test.exs +++ b/apps/explorer/test/explorer/chain/import_test.exs @@ -1459,5 +1459,57 @@ defmodule Explorer.Chain.ImportTest do ) ) end + + test "timeouts can be overridden" do + assert {:ok, _} = + Import.all(%{ + addresses: %{ + params: [], + timeout: 1 + }, + balances: %{ + params: [], + timeout: 1 + }, + blocks: %{ + params: [], + timeout: 1 + }, + block_second_degree_relations: %{ + params: [], + timeout: 1 + }, + internal_transactions: %{ + params: [], + timeout: 1 + }, + logs: %{ + params: [], + timeout: 1 + }, + token_transfers: %{ + params: [], + timeout: 1 + }, + tokens: %{ + params: [], + on_conflict: :replace_all, + timeout: 1 + }, + transactions: %{ + params: [], + on_conflict: :replace_all, + timeout: 1 + }, + transaction_forks: %{ + params: [], + timeout: 1 + }, + token_balances: %{ + params: [], + timeout: 1 + } + }) + end end end