|
|
|
@ -72,6 +72,25 @@ defmodule Explorer.MarketTest do |
|
|
|
|
assert missing_records == %{} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
test "doesn't replace existing records with zeros" do |
|
|
|
|
date = ~D[2018-04-01] |
|
|
|
|
|
|
|
|
|
{:ok, old_record} = |
|
|
|
|
Repo.insert(%MarketHistory{date: date, closing_price: Decimal.new(1), opening_price: Decimal.new(1)}) |
|
|
|
|
|
|
|
|
|
new_record = %{ |
|
|
|
|
date: date, |
|
|
|
|
closing_price: Decimal.new(0), |
|
|
|
|
opening_price: Decimal.new(0) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Market.bulk_insert_history([new_record]) |
|
|
|
|
|
|
|
|
|
fetched_record = Repo.get_by(MarketHistory, date: date) |
|
|
|
|
assert fetched_record.closing_price == old_record.closing_price |
|
|
|
|
assert fetched_record.opening_price == old_record.opening_price |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
test "overrides existing records on date conflict" do |
|
|
|
|
date = ~D[2018-04-01] |
|
|
|
|
Repo.insert(%MarketHistory{date: date}) |
|
|
|
|