Skip to content

Commit

Permalink
Merge 5b065f6 into cd4fee7
Browse files Browse the repository at this point in the history
  • Loading branch information
simonewebdesign committed Mar 3, 2017
2 parents cd4fee7 + 5b065f6 commit 7aa92b9
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 6 deletions.
5 changes: 2 additions & 3 deletions lib/live_odds/account.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ defmodule LiveOdds.Account do
A bank account.
"""


@doc "Open a bank account."
@spec start() :: {:ok, pid} | {:error, {:already_started, pid} | term}
def start do
@spec start_link() :: {:ok, pid} | {:error, {:already_started, pid} | term}
def start_link do
Agent.start(fn -> 0 end, [name: :account])
end

Expand Down
18 changes: 18 additions & 0 deletions lib/live_odds/supervisor.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
defmodule LiveOdds.Supervisor do
@moduledoc false

use Supervisor

def start_link do
Supervisor.start_link(__MODULE__, [])
end

def init([]) do
children = [
worker(LiveOdds.Account, []),
worker(PubSub, []),
]

supervise(children, strategy: :one_for_one)
end
end
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ defmodule LiveOdds.Mixfile do
{:credo, "> 0.0.0", only: [:dev, :test]},
{:ex_doc, "> 0.0.0", only: :dev},
{:excoveralls, "> 0.0.0", only: :test},
{:dialyxir, "> 0.0.0", only: :dev, runtime: false}
{:dialyxir, "> 0.0.0", only: :dev, runtime: false},
{:pubsub, "0.0.2"},
]
end
end
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []},
"mix_test_watch": {:hex, :mix_test_watch, "0.3.3", "70859889a8d1d43d1b75d69d87258a301f43209a17787cdb2bd9cab42adf271d", [:mix], [{:fs, "~> 2.12", [hex: :fs, optional: false]}]},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []},
"pubsub": {:hex, :pubsub, "0.0.2", "0b48c4ea81625e1119a116243ba212f025b188d018a474e61fe48705aff5a36f", [:mix], []},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []}}
3 changes: 1 addition & 2 deletions test/live_odds/account_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ defmodule AccountTest do
use ExUnit.Case
alias LiveOdds.Account


setup do
{:ok, _pid} = Account.start()
{:ok, _pid} = Account.start_link()

on_exit(fn() ->
:ok = Account.stop()
Expand Down
20 changes: 20 additions & 0 deletions test/live_odds/supervisor_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
defmodule SupervisorTest do

use ExUnit.Case

setup do
{:ok, pid} = LiveOdds.Supervisor.start_link()
{:ok, [pid: pid]}
end

test "it's alive!", %{pid: pid} do
assert Process.alive?(pid)
end

test "starts Account and PubSub", %{pid: pid} do
[{PubSub, _, _, _},
{LiveOdds.Account, _, _, _},
] = Supervisor.which_children(pid)
end

end

0 comments on commit 7aa92b9

Please sign in to comment.