From 455f2da7221921780e82d9896e467c452b90da7c Mon Sep 17 00:00:00 2001 From: Cam Date: Tue, 5 Jun 2018 19:08:02 -0700 Subject: [PATCH 1/2] Bump httpoison --- mix.exs | 3 +-- mix.lock | 14 +++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/mix.exs b/mix.exs index ef446bb..6758f13 100644 --- a/mix.exs +++ b/mix.exs @@ -53,8 +53,7 @@ defmodule Grapple.Mixfile do # Type "mix help deps" for more examples and options defp deps do [ - {:graphql, "~> 0.3"}, - {:httpoison, "~> 0.9.0"}, + {:httpoison, "~> 1.0"}, {:gen_stage, "~> 0.4"}, {:ex_doc, "~> 0.13", only: :dev}, ] diff --git a/mix.lock b/mix.lock index bc710e5..5cf557d 100644 --- a/mix.lock +++ b/mix.lock @@ -1,18 +1,22 @@ -%{"certifi": {:hex, :certifi, "0.7.0", "861a57f3808f7eb0c2d1802afeaae0fa5de813b0df0979153cbafcd853ababaf", [:rebar3], []}, +%{ + "certifi": {:hex, :certifi, "2.3.1", "d0f424232390bf47d82da8478022301c561cf6445b5b5fb6a84d49a9e76d2639", [:rebar3], [{:parse_trans, "3.2.0", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, "combine": {:hex, :combine, "0.9.3", "192e609b48b3f2210494e26f85db1712657be1a8f15795656710317ea43fc449", [:mix], []}, "earmark": {:hex, :earmark, "1.0.3", "89bdbaf2aca8bbb5c97d8b3b55c5dd0cff517ecc78d417e87f1d0982e514557b", [:mix], []}, "ex_doc": {:hex, :ex_doc, "0.14.4", "a0a79a6896075814f4bc6802b74ccbed6549f47cc5ab34c71eaee2303170b8ef", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]}, "gen_stage": {:hex, :gen_stage, "0.9.0", "9daf0b5ae224405e0456b7df5a282a9a958176cdb9b963811ca38140e7e1b3c4", [:mix], []}, "gettext": {:hex, :gettext, "0.12.1", "c0624f52763469ef7a3674919ae28b8286d88195b90fa1516180f31bbbd26d14", [:mix], []}, "graphql": {:hex, :graphql, "0.3.2", "0aa7a00948c456831f8fa1bb4ead3e4e15d145b8656902134d180d1369775dff", [:mix], []}, - "hackney": {:hex, :hackney, "1.6.3", "d489d7ca2d4323e307bedc4bfe684323a7bf773ecfd77938f3ee8074e488e140", [:mix, :rebar3], [{:certifi, "0.7.0", [hex: :certifi, optional: false]}, {:idna, "1.2.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]}, - "httpoison": {:hex, :httpoison, "0.9.2", "a211a8e87403a043c41218e64df250d321f236ac57f786c6a0ccf3e9e817c819", [:mix], [{:hackney, "~> 1.6.0", [hex: :hackney, optional: false]}]}, - "idna": {:hex, :idna, "1.2.0", "ac62ee99da068f43c50dc69acf700e03a62a348360126260e87f2b54eced86b2", [:rebar3], []}, + "hackney": {:hex, :hackney, "1.12.1", "8bf2d0e11e722e533903fe126e14d6e7e94d9b7983ced595b75f532e04b7fdc7", [:rebar3], [{:certifi, "2.3.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.1", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, + "httpoison": {:hex, :httpoison, "1.1.1", "96ed7ab79f78a31081bb523eefec205fd2900a02cda6dbc2300e7a1226219566", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "idna": {:hex, :idna, "5.1.1", "cbc3b2fa1645113267cc59c760bafa64b2ea0334635ef06dbac8801e42f7279c", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []}, "mime": {:hex, :mime, "1.0.1", "05c393850524767d13a53627df71beeebb016205eb43bfbd92d14d24ec7a1b51", [:mix], []}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []}, + "parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"}, "plug": {:hex, :plug, "1.2.2", "cfbda521b54c92ab8ddffb173fbaabed8d8fc94bec07cd9bb58a84c1c501b0bd", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []}, "timex": {:hex, :timex, "3.1.5", "413d6d8d6f0162a5d47080cb8ca520d790184ac43e097c95191c7563bf25b428", [:mix], [{:combine, "~> 0.7", [hex: :combine, optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, optional: false]}]}, "tzdata": {:hex, :tzdata, "0.5.9", "575be217b039057a47e133b72838cbe104fb5329b19906ea4e66857001c37edb", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, optional: false]}]}, - "uuid": {:hex, :uuid, "1.1.5", "96cb36d86ee82f912efea4d50464a5df606bf3f1163d6bdbb302d98474969369", [:mix], []}} + "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}, + "uuid": {:hex, :uuid, "1.1.5", "96cb36d86ee82f912efea4d50464a5df606bf3f1163d6bdbb302d98474969369", [:mix], []}, +} From 792955eac53d6dd04d4606eb68e31cb53da8ca3e Mon Sep 17 00:00:00 2001 From: Cam Date: Tue, 5 Jun 2018 19:09:38 -0700 Subject: [PATCH 2/2] Add .formatter.exs & run mix format --- .formatter.exs | 3 ++ config/config.exs | 2 +- lib/grapple.ex | 12 ++--- lib/grapple/hook.ex | 44 +++++++++--------- lib/grapple/hook_server.ex | 11 ++--- lib/grapple/server.ex | 45 +++++++++--------- lib/grapple/supervisor.ex | 2 +- lib/grapple/topic_supervisor.ex | 3 +- mix.exs | 37 +++++++-------- test/hook_test.exs | 81 +++++++++++++++++---------------- test/support/http_client.ex | 4 +- test/topic_test.exs | 18 ++++---- 12 files changed, 135 insertions(+), 127 deletions(-) create mode 100644 .formatter.exs diff --git a/.formatter.exs b/.formatter.exs new file mode 100644 index 0000000..d304ff3 --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,3 @@ +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/config/config.exs b/config/config.exs index 39bcaf6..d64ecdf 100644 --- a/config/config.exs +++ b/config/config.exs @@ -27,4 +27,4 @@ use Mix.Config # Configuration from the imported file will override the ones defined # here (which is why it is important to import them last). # -import_config "#{Mix.env}.exs" +import_config "#{Mix.env()}.exs" diff --git a/lib/grapple.ex b/lib/grapple.ex index 475aff6..c02904e 100644 --- a/lib/grapple.ex +++ b/lib/grapple.ex @@ -8,7 +8,7 @@ defmodule Grapple do use Application def start(_type, _args) do - Grapple.Supervisor.start_link [] + Grapple.Supervisor.start_link([]) end # Topics @@ -43,7 +43,7 @@ defmodule Grapple do true """ def get_topics do - Grapple.Server.get_topics + Grapple.Server.get_topics() end @doc """ @@ -52,7 +52,7 @@ defmodule Grapple do Returns `:ok`. """ def clear_topics do - Grapple.Server.clear_topics + Grapple.Server.clear_topics() end # Hooks @@ -194,10 +194,10 @@ defmodule Grapple do defmacro defhook({name, _, _} = func, do: block) do quote do def unquote(func) do - topic = unquote name - result = unquote block + topic = unquote(name) + result = unquote(block) - broadcast topic, result + broadcast(topic, result) result end diff --git a/lib/grapple/hook.ex b/lib/grapple/hook.ex index a0c21f7..96e3671 100644 --- a/lib/grapple/hook.ex +++ b/lib/grapple/hook.ex @@ -15,45 +15,45 @@ defmodule Grapple.Hook do body: %{}, headers: [], options: [], - query: %{}, + query: %{} ] # API def start_link(hook) do - GenServer.start_link __MODULE__, hook + GenServer.start_link(__MODULE__, hook) end def get_info(pid) do - GenServer.call pid, :get_info + GenServer.call(pid, :get_info) end def get_responses(pid) do - GenServer.call pid, :get_responses + GenServer.call(pid, :get_responses) end def start_polling(pid) do - GenServer.call pid, :start_polling + GenServer.call(pid, :start_polling) end def start_polling(pid, interval) when is_integer(interval) do - GenServer.call pid, {:start_polling, interval} + GenServer.call(pid, {:start_polling, interval}) end def broadcast(pid) do - GenServer.cast pid, :broadcast + GenServer.cast(pid, :broadcast) end def broadcast(pid, body) when is_nil(body) do - GenServer.cast pid, :broadcast + GenServer.cast(pid, :broadcast) end def broadcast(pid, body) do - GenServer.cast pid, {:broadcast, body} + GenServer.cast(pid, {:broadcast, body}) end def stop_polling(pid) do - GenServer.cast pid, :stop_polling + GenServer.cast(pid, :stop_polling) end # Callbacks @@ -80,6 +80,7 @@ defmodule Grapple.Hook do case interval do nil -> {:reply, {:error, "No interval specified, use `start_polling/2`."}, state} + _ -> {:ok, tref} = start_timer(interval) @@ -95,19 +96,19 @@ defmodule Grapple.Hook do end def handle_cast(:broadcast, %{hook: hook, responses: responses} = state) do - response = notify(hook, hook.body) - new_state = %{state | responses: [response | responses]} - send_to_owner(hook, response) + response = notify(hook, hook.body) + new_state = %{state | responses: [response | responses]} + send_to_owner(hook, response) - {:noreply, new_state} + {:noreply, new_state} end def handle_cast({:broadcast, body}, %{hook: hook, responses: responses} = state) do - response = notify(hook, body) - new_state = %{state | responses: [response | responses]} - send_to_owner(hook, response) + response = notify(hook, body) + new_state = %{state | responses: [response | responses]} + send_to_owner(hook, response) - {:noreply, new_state} + {:noreply, new_state} end def handle_cast(:stop_polling, %{tref: tref} = state) do @@ -136,7 +137,7 @@ defmodule Grapple.Hook do defp send_to_owner(%{owner: owner}, response) when is_pid(owner) do if Process.alive?(owner) do - send(owner, {:hook_response, self, response}) + send(owner, {:hook_response, self(), response}) end end @@ -144,10 +145,7 @@ defmodule Grapple.Hook do defp start_timer(interval) do # Uses Erlang :timer to `broadcast` at the given interval - :timer.apply_interval(interval, - __MODULE__, - :broadcast, - [self]) + :timer.apply_interval(interval, __MODULE__, :broadcast, [self()]) end defp stop_timer(tref) when is_nil(tref) do diff --git a/lib/grapple/hook_server.ex b/lib/grapple/hook_server.ex index e955734..d1ff969 100644 --- a/lib/grapple/hook_server.ex +++ b/lib/grapple/hook_server.ex @@ -42,9 +42,9 @@ defmodule Grapple.HookServer do end def handle_call({:subscribe, hook}, _from, %{hook_sup: hook_sup} = state) do - pid = add_hook(hook, hook_sup) + pid = add_hook(hook, hook_sup) - {:reply, {:ok, pid}, state} + {:reply, {:ok, pid}, state} end def handle_call(:get_hooks, _from, %{hook_sup: hook_sup} = state) do @@ -65,11 +65,10 @@ defmodule Grapple.HookServer do {:reply, responses, state} end - def handle_cast({:remove_hook, hook_pid}, - %{hook_sup: hook_sup} = state) do - HookSupervisor.terminate_child(hook_sup, hook_pid) + def handle_cast({:remove_hook, hook_pid}, %{hook_sup: hook_sup} = state) do + HookSupervisor.terminate_child(hook_sup, hook_pid) - {:noreply, state} + {:noreply, state} end def handle_cast(:broadcast, %{hook_sup: hook_sup} = state) do diff --git a/lib/grapple/server.ex b/lib/grapple/server.ex index 7d16e95..af82c81 100644 --- a/lib/grapple/server.ex +++ b/lib/grapple/server.ex @@ -3,7 +3,7 @@ defmodule Grapple.Server do use GenServer defmodule Topic do - defstruct [:sup, :name,] + defstruct [:sup, :name] end alias Grapple.TopicsSupervisor @@ -76,16 +76,17 @@ defmodule Grapple.Server do end def handle_call({:add_topic, topic_name}, _from, %{topics: topics} = state) do - topic = Enum.find(topics, fn topic -> topic.name == topic_name end) + topic = Enum.find(topics, fn topic -> topic.name == topic_name end) - case topic do - nil -> - {:ok, sup} = TopicsSupervisor.start_child(topic_name) - new_topic = %Topic{sup: sup, name: topic_name} - {:reply, {:ok, new_topic}, %{state | topics: [new_topic | topics]}} - topic -> - {:reply, {:ok, topic}, state} - end + case topic do + nil -> + {:ok, sup} = TopicsSupervisor.start_child(topic_name) + new_topic = %Topic{sup: sup, name: topic_name} + {:reply, {:ok, new_topic}, %{state | topics: [new_topic | topics]}} + + topic -> + {:reply, {:ok, topic}, state} + end end def handle_call(:get_topics, _from, %{topics: topics} = state) do @@ -93,22 +94,22 @@ defmodule Grapple.Server do end def handle_call(:clear_topics, _from, %{topics: topics} = state) do - Enum.each(topics, &(TopicsSupervisor.terminate_child(&1.sup))) + Enum.each(topics, &TopicsSupervisor.terminate_child(&1.sup)) - {:reply, :ok, %{state | topics: []}} + {:reply, :ok, %{state | topics: []}} end def handle_cast({:remove_topic, topic_name}, %{topics: topics} = state) do - topic = Enum.find(topics, fn topic -> topic.name == topic_name end) + topic = Enum.find(topics, fn topic -> topic.name == topic_name end) + + case topic do + nil -> + {:noreply, state} - case topic do - nil -> - {:noreply, state} - %Topic{} -> - TopicsSupervisor.terminate_child(topic.sup) - new_topics = List.delete(topics, topic) - {:noreply, %{state | topics: new_topics}} - end + %Topic{} -> + TopicsSupervisor.terminate_child(topic.sup) + new_topics = List.delete(topics, topic) + {:noreply, %{state | topics: new_topics}} + end end end - diff --git a/lib/grapple/supervisor.ex b/lib/grapple/supervisor.ex index c3ab814..e242f06 100644 --- a/lib/grapple/supervisor.ex +++ b/lib/grapple/supervisor.ex @@ -18,6 +18,6 @@ defmodule Grapple.Supervisor do end def init(_) do - supervise [], strategy: :one_for_all + supervise([], strategy: :one_for_all) end end diff --git a/lib/grapple/topic_supervisor.ex b/lib/grapple/topic_supervisor.ex index 76215ac..bcff956 100644 --- a/lib/grapple/topic_supervisor.ex +++ b/lib/grapple/topic_supervisor.ex @@ -12,6 +12,7 @@ defmodule Grapple.TopicSupervisor do supervisor(Grapple.HookSupervisor, [topic]), worker(Grapple.HookServer, [topic]) ] - supervise children, strategy: :one_for_all + + supervise(children, strategy: :one_for_all) end end diff --git a/mix.exs b/mix.exs index 6758f13..059aadd 100644 --- a/mix.exs +++ b/mix.exs @@ -2,27 +2,28 @@ defmodule Grapple.Mixfile do use Mix.Project def project do - [app: :grapple, - version: "1.2.3", - elixir: "~> 1.6.4", - build_embedded: Mix.env == :prod, - start_permanent: Mix.env == :prod, - description: "Webhook magic in Elixir", - package: package, - deps: deps(), - elixirc_paths: elixirc_paths(Mix.env), + [ + app: :grapple, + version: "1.2.3", + elixir: "~> 1.6.4", + build_embedded: Mix.env() == :prod, + start_permanent: Mix.env() == :prod, + description: "Webhook magic in Elixir", + package: package(), + deps: deps(), + elixirc_paths: elixirc_paths(Mix.env()), - # Docs - name: "Grapple", - source_url: "https://github.com/camirmas/grapple", - docs: [# logo: "", - canonical: "https://hexdocs.com/grapple", - extras: ["README.md"]]] + # Docs + name: "Grapple", + source_url: "https://github.com/camirmas/grapple", + # logo: "", + docs: [canonical: "https://hexdocs.com/grapple", extras: ["README.md"]] + ] end # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/support"] - defp elixirc_paths(_), do: ["lib"] + defp elixirc_paths(_), do: ["lib"] def package do [ @@ -38,7 +39,7 @@ defmodule Grapple.Mixfile do def application do [ applications: [:httpoison, :logger, :gen_stage], - mod: {Grapple, []}, + mod: {Grapple, []} ] end @@ -55,7 +56,7 @@ defmodule Grapple.Mixfile do [ {:httpoison, "~> 1.0"}, {:gen_stage, "~> 0.4"}, - {:ex_doc, "~> 0.13", only: :dev}, + {:ex_doc, "~> 0.13", only: :dev} ] end end diff --git a/test/hook_test.exs b/test/hook_test.exs index dd405dd..db9a128 100644 --- a/test/hook_test.exs +++ b/test/hook_test.exs @@ -6,8 +6,8 @@ defmodule HookTest do @hook %Hook{url: "/stuff"} setup do - Grapple.clear_topics - {:ok, topic} = Grapple.add_topic :pokemon + Grapple.clear_topics() + {:ok, topic} = Grapple.add_topic(:pokemon) hook = Map.put(@hook, :owner, self()) [topic: topic, hook: hook] @@ -37,15 +37,17 @@ defmodule HookTest do assert [{^pid, []}] = Grapple.get_responses(topic.name) end - test "if a hook goes down in an abnormal way, it should be restarted", - %{topic: topic, hook: hook} do - {:ok, pid} = Grapple.subscribe(topic.name, hook) - ref = Process.monitor(pid) - Process.exit(pid, :kill) - assert_receive {:DOWN, ^ref, _, _, _} + test "if a hook goes down in an abnormal way, it should be restarted", %{ + topic: topic, + hook: hook + } do + {:ok, pid} = Grapple.subscribe(topic.name, hook) + ref = Process.monitor(pid) + Process.exit(pid, :kill) + assert_receive {:DOWN, ^ref, _, _, _} - assert [{new_pid, %Hook{}}] = Grapple.get_hooks(topic.name) - refute new_pid == pid + assert [{new_pid, %Hook{}}] = Grapple.get_hooks(topic.name) + refute new_pid == pid end end @@ -82,22 +84,23 @@ defmodule HookTest do end describe "hook polling" do - test "can subscribe a hook with immediate polling", %{topic: topic, - hook: hook} do - hook = Map.put(hook, :interval, 1) - {:ok, pid} = Grapple.subscribe(topic.name, hook) + test "can subscribe a hook with immediate polling", %{topic: topic, hook: hook} do + hook = Map.put(hook, :interval, 1) + {:ok, pid} = Grapple.subscribe(topic.name, hook) - assert_receive {:hook_response, ^pid, response} - assert response == {:ok, %{body: %{}, status_code: 200}} + assert_receive {:hook_response, ^pid, response} + assert response == {:ok, %{body: %{}, status_code: 200}} end - test "can subscribe a hook without polling, but can start it later", - %{topic: topic, hook: hook} do - {:ok, pid} = Grapple.subscribe(topic.name, hook) + test "can subscribe a hook without polling, but can start it later", %{ + topic: topic, + hook: hook + } do + {:ok, pid} = Grapple.subscribe(topic.name, hook) - assert Grapple.start_polling(pid, 1) == :ok - assert_receive {:hook_response, ^pid, response} - assert response == {:ok, %{body: %{}, status_code: 200}} + assert Grapple.start_polling(pid, 1) == :ok + assert_receive {:hook_response, ^pid, response} + assert response == {:ok, %{body: %{}, status_code: 200}} end test "cannot start polling without an interval", %{topic: topic, hook: hook} do @@ -129,33 +132,35 @@ defmodule HookTest do describe "defhook" do use Grapple - test "hooks defined with the macro will broadcast to topics of the same name", - %{topic: topic, hook: hook} do - {:ok, pid} = Grapple.subscribe(topic.name, hook) + test "hooks defined with the macro will broadcast to topics of the same name", %{ + topic: topic, + hook: hook + } do + {:ok, pid} = Grapple.subscribe(topic.name, hook) - defmodule Hookable do - defhook pokemon do - end + defmodule Hookable do + defhook pokemon do end + end - Hookable.pokemon() + Hookable.pokemon() - assert_receive {:hook_response, ^pid, response} - assert response == {:ok, %{body: %{}, status_code: 200}} + assert_receive {:hook_response, ^pid, response} + assert response == {:ok, %{body: %{}, status_code: 200}} end test "hooks defined with the macro (with args) will broadcast to topics of the same name", %{topic: topic, hook: hook} do - {:ok, pid} = Grapple.subscribe(topic.name, hook) + {:ok, pid} = Grapple.subscribe(topic.name, hook) - defmodule HookableArgs do - defhook pokemon(name), do: name - end + defmodule HookableArgs do + defhook(pokemon(name), do: name) + end - HookableArgs.pokemon("dragonite") + HookableArgs.pokemon("dragonite") - assert_receive {:hook_response, ^pid, response} - assert response == {:ok, %{body: %{}, status_code: 200}} + assert_receive {:hook_response, ^pid, response} + assert response == {:ok, %{body: %{}, status_code: 200}} end end end diff --git a/test/support/http_client.ex b/test/support/http_client.ex index 0a15f0d..609c166 100644 --- a/test/support/http_client.ex +++ b/test/support/http_client.ex @@ -1,11 +1,12 @@ defmodule Grapple.Test.HttpClient do - def get("NOT_FOUND", _headers, _options) do {:ok, %{status_code: 404}} end + def get("ERROR", _headers, _options) do {:error, %{reason: ""}} end + def get(_url, _headers, _options) do {:ok, %{status_code: 200, body: %{}}} end @@ -21,5 +22,4 @@ defmodule Grapple.Test.HttpClient do def delete(_url, _headers, _options) do {:ok, %{status_code: 200, body: %{}}} end - end diff --git a/test/topic_test.exs b/test/topic_test.exs index 3c5bb56..e47a24b 100644 --- a/test/topic_test.exs +++ b/test/topic_test.exs @@ -3,32 +3,32 @@ defmodule TopicTest do describe "topics" do setup do - Grapple.clear_topics + Grapple.clear_topics() end test "can get topics" do - assert [] = Grapple.get_topics + assert [] = Grapple.get_topics() end test "can add topics" do - {:ok, pokemon} = Grapple.add_topic :pokemon - {:ok, gyms} = Grapple.add_topic :gyms - topics = Grapple.get_topics + {:ok, pokemon} = Grapple.add_topic(:pokemon) + {:ok, gyms} = Grapple.add_topic(:gyms) + topics = Grapple.get_topics() assert gyms in topics assert pokemon in topics end test "can remove topics" do - {:ok, pokemon} = Grapple.add_topic :pokemon + {:ok, pokemon} = Grapple.add_topic(:pokemon) ref = Process.monitor(pokemon.name) - Grapple.remove_topic :pokemon + Grapple.remove_topic(:pokemon) assert_receive {:DOWN, ^ref, _, _, :shutdown} end test "can get all topics" do - {:ok, gyms} = Grapple.add_topic :gyms - topics = Grapple.get_topics + {:ok, gyms} = Grapple.add_topic(:gyms) + topics = Grapple.get_topics() assert gyms in topics end