diff options
author | Hubert Chathi <hubert@uhoreg.ca> | 2020-09-16 00:06:13 -0400 |
---|---|---|
committer | Hubert Chathi <hubert@uhoreg.ca> | 2020-09-16 00:06:13 -0400 |
commit | 76ba0ed6c0577f671ee7b9a865333c264d1985a0 (patch) | |
tree | 5cf6a3f6f6c366cbab42588944e6a8103aecd53a /test/polyjuice | |
parent | make Polyjuice.Client.start_link return {:ok, pid}, like a normal start_link (diff) |
change structure of Polyjuice.Client process tree
Diffstat (limited to 'test/polyjuice')
-rw-r--r-- | test/polyjuice/client/sync_test.exs | 8 | ||||
-rw-r--r-- | test/polyjuice/client_test.exs | 40 |
2 files changed, 10 insertions, 38 deletions
diff --git a/test/polyjuice/client/sync_test.exs b/test/polyjuice/client/sync_test.exs index e1085d6..94387aa 100644 --- a/test/polyjuice/client/sync_test.exs +++ b/test/polyjuice/client/sync_test.exs @@ -440,9 +440,7 @@ defmodule Polyjuice.Client.SyncTest do Process.sleep(10) assert Polyjuice.Client.process_name(client.id, :supervisor) - |> Supervisor.which_children() - |> Enum.find_value(fn {id, pid, _, _} -> if id == Polyjuice.Client.Sync, do: pid end) == - :undefined + |> DynamicSupervisor.which_children() == [] Polyjuice.Client.API.stop(client) @@ -495,9 +493,7 @@ defmodule Polyjuice.Client.SyncTest do Process.sleep(10) assert Polyjuice.Client.process_name(client.id, :supervisor) - |> Supervisor.which_children() - |> Enum.find_value(fn {id, pid, _, _} -> if id == Polyjuice.Client.Sync, do: pid end) == - :undefined + |> DynamicSupervisor.which_children() == [] Polyjuice.Client.API.stop(client) diff --git a/test/polyjuice/client_test.exs b/test/polyjuice/client_test.exs index d9f95a8..96dc829 100644 --- a/test/polyjuice/client_test.exs +++ b/test/polyjuice/client_test.exs @@ -235,10 +235,7 @@ defmodule Polyjuice.ClientTest do Polyjuice.Client.log_in_with_password(client, "@alice:example.org", "password") - assert Agent.get( - Polyjuice.Client.process_name(client.id, :state), - &Map.take(&1, [:access_token, :user_id, :device_id]) - ) == %{ + assert GenServer.call(client.pid, :get_state) == %{ access_token: "m.id.user_login", user_id: "@alice:example.org", device_id: "foo" @@ -264,10 +261,7 @@ defmodule Polyjuice.ClientTest do assert Polyjuice.Client.Storage.kv_get(storage, "ca.uhoreg.polyjuice", "user_id") == nil assert Polyjuice.Client.Storage.kv_get(storage, "ca.uhoreg.polyjuice", "device_id") == nil - assert Agent.get( - Polyjuice.Client.process_name(client.id, :state), - &Map.fetch!(&1, :access_token) - ) == nil + assert GenServer.call(client.pid, :get_state) |> Map.get(:access_token) == nil Polyjuice.Client.log_in_with_password( client, @@ -277,10 +271,7 @@ defmodule Polyjuice.ClientTest do assert_receive({:polyjuice_client, :logged_in, {"@alice:example.org", "foo", _}}) - assert Agent.get( - Polyjuice.Client.process_name(client.id, :state), - &Map.take(&1, [:access_token, :user_id, :device_id]) - ) == %{ + assert GenServer.call(client.pid, :get_state) == %{ access_token: "m.id.thirdparty_login", user_id: "@alice:example.org", device_id: "foo" @@ -294,10 +285,7 @@ defmodule Polyjuice.ClientTest do assert_receive({:polyjuice_client, :logged_in, {"@alice:example.org", "foo", _}}) - assert Agent.get( - Polyjuice.Client.process_name(client.id, :state), - &Map.take(&1, [:access_token, :user_id, :device_id]) - ) == %{ + assert GenServer.call(client.pid, :get_state) == %{ access_token: "m.id.phone_login", user_id: "@alice:example.org", device_id: "foo" @@ -313,10 +301,7 @@ defmodule Polyjuice.ClientTest do assert_receive({:polyjuice_client, :logged_in, {"@alice:example.org", "foo", _}}) - assert Agent.get( - Polyjuice.Client.process_name(client.id, :state), - &Map.take(&1, [:access_token, :user_id, :device_id]) - ) == %{ + assert GenServer.call(client.pid, :get_state) == %{ access_token: "ca.uhoreg.foo_login", user_id: "@alice:example.org", device_id: "foo" @@ -349,10 +334,7 @@ defmodule Polyjuice.ClientTest do client = Polyjuice.Client.get_client(client_pid) - assert Agent.get( - Polyjuice.Client.process_name(client.id, :state), - &Map.take(&1, [:access_token, :user_id, :device_id]) - ) == %{ + assert GenServer.call(client.pid, :get_state) == %{ access_token: "an_access_token", user_id: "@alice:example.org", device_id: "a_device" @@ -382,10 +364,7 @@ defmodule Polyjuice.ClientTest do client2 = Polyjuice.Client.get_client(client2_pid) - assert Agent.get( - Polyjuice.Client.process_name(client2.id, :state), - &Map.take(&1, [:access_token, :user_id, :device_id]) - ) == %{ + assert GenServer.call(client2.pid, :get_state) == %{ access_token: "an_access_token", user_id: "@alice:example.org", device_id: "a_device" @@ -431,10 +410,7 @@ defmodule Polyjuice.ClientTest do Polyjuice.Client.Room.send_event(client, "!a_room:example.org", "m.room.message", %{}) - assert Agent.get( - Polyjuice.Client.process_name(client.id, :state), - &Map.fetch!(&1, :access_token) - ) == nil + assert GenServer.call(client.pid, :get_state) |> Map.get(:state) == nil assert Polyjuice.Client.Storage.kv_get(storage, "ca.uhoreg.polyjuice", "access_token") == nil |