Skip to content

Commit

Permalink
test: add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
borgoat committed Apr 13, 2023
1 parent c568fa2 commit 23f96ae
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions test/integration.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
defmodule MockHandler do
@behaviour ExTwelveData.RealTimePrices.Handler

require Logger

@impl true
def handle_price_update(price) do
Logger.info(price)
end
end

{:ok, pid} =
ExTwelveData.RealTimePrices.start_link(
api_key: System.fetch_env!("TWELVE_DATA_API_KEY"),
handler: MockHandler
)

alias ExTwelveData.RealTimePrices.SubscriptionsManager

defmodule MockProvider do
alias ExTwelveData.Symbol
@behaviour SubscriptionsManager.Provider

require Logger

@impl true
def get_symbols() do
new =
MapSet.new(
Enum.random([
[
%Symbol{exchange: "Euronext", symbol: "SLBEN"},
%Symbol{mic_code: "XPAR", symbol: "ALMIL"},
%Symbol{type: "Index", symbol: "IXIC"}
],
[
%Symbol{mic_code: "XDUS", symbol: "ADS"},
%Symbol{mic_code: "XFRA", symbol: "MQ1"},
%Symbol{type: "Index", symbol: "VFIAX"}
]
])
)

Logger.warning(new)

new
end
end

SubscriptionsManager.start_link(
pid: pid,
provider: MockProvider,
max_subscriptions: 8,
symbols_extended: true
)

# ["AAPL", "MSFT", "GOOG"],
# ["TSLA", "MSFT", "ABML"],
# ["IXIC", "VFIAX", "QQQ"]

0 comments on commit 23f96ae

Please sign in to comment.