|
|
|
@ -91,9 +91,11 @@ defmodule Explorer.MarketTest do |
|
|
|
|
assert fetched_record.opening_price == old_record.opening_price |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
test "overrides existing records on date conflict" do |
|
|
|
|
test "does not override existing records on date conflict" do |
|
|
|
|
date = ~D[2018-04-01] |
|
|
|
|
Repo.insert(%MarketHistory{date: date}) |
|
|
|
|
|
|
|
|
|
{:ok, old_record} = |
|
|
|
|
Repo.insert(%MarketHistory{date: date, closing_price: Decimal.new(2), opening_price: Decimal.new(2)}) |
|
|
|
|
|
|
|
|
|
new_record = %{ |
|
|
|
|
date: date, |
|
|
|
@ -104,8 +106,8 @@ defmodule Explorer.MarketTest do |
|
|
|
|
Market.bulk_insert_history([new_record]) |
|
|
|
|
|
|
|
|
|
fetched_record = Repo.get_by(MarketHistory, date: date) |
|
|
|
|
assert fetched_record.closing_price == new_record.closing_price |
|
|
|
|
assert fetched_record.opening_price == new_record.opening_price |
|
|
|
|
assert fetched_record.closing_price == old_record.closing_price |
|
|
|
|
assert fetched_record.opening_price == old_record.opening_price |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|