summaryrefslogtreecommitdiff
path: root/test/polyjuice/client/sync_test.exs
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2020-08-21 19:03:00 -0400
committerHubert Chathi <hubert@uhoreg.ca>2020-08-21 19:03:00 -0400
commit062b89962018f88c9390d7ba0822a99c68756c94 (patch)
tree982cbd9b21194284110c367a65f76890e9a072cc /test/polyjuice/client/sync_test.exs
parentadd lower-level client, acting like the old client (diff)
automatically start sync process
Diffstat (limited to 'test/polyjuice/client/sync_test.exs')
-rw-r--r--test/polyjuice/client/sync_test.exs121
1 files changed, 60 insertions, 61 deletions
diff --git a/test/polyjuice/client/sync_test.exs b/test/polyjuice/client/sync_test.exs
index c1b4f64..a910c14 100644
--- a/test/polyjuice/client/sync_test.exs
+++ b/test/polyjuice/client/sync_test.exs
@@ -214,100 +214,99 @@ defmodule Polyjuice.Client.SyncTest do
port = :httpd.info(httpd_pid) |> Keyword.fetch!(:port)
client =
- Polyjuice.Client.start(
+ Polyjuice.Client.start_link(
"http://127.0.0.1:#{port}/Elixir.Polyjuice.Client.SyncTest.Httpd",
access_token: "an_access_token",
user_id: "@alice:example.org",
+ handler: self(),
storage: storage,
+ sync_filter: %{},
test: true
)
- {:ok, sync_pid} =
- Polyjuice.Client.API.sync_child_spec(client, self(), filter: %{})
- |> (fn %{start: {module, func, args}} -> apply(module, func, args) end).()
-
- assert_receive({:connected})
+ assert_receive({:polyjuice_client, :sync_connected})
assert_receive(
- {:invite, "!room_id", "@bob:example.org",
- %{
- "m.room.member" => %{
- "@alice:example.org" => %{
- "content" => %{
- "membership" => "invite"
- },
- "type" => "m.room.member",
- "state_key" => "@alice:example.org",
- "event_id" => "$invite_event",
- "room_id" => "!room_id",
- "sender" => "@bob:example.org"
- }
- }
- }},
+ {:polyjuice_client, :invite,
+ {"!room_id", "@bob:example.org",
+ %{
+ "m.room.member" => %{
+ "@alice:example.org" => %{
+ "content" => %{
+ "membership" => "invite"
+ },
+ "type" => "m.room.member",
+ "state_key" => "@alice:example.org",
+ "event_id" => "$invite_event",
+ "room_id" => "!room_id",
+ "sender" => "@bob:example.org"
+ }
+ }
+ }}},
1000
)
- assert_receive({:initial_sync_completed})
+ assert_receive({:polyjuice_client, :initial_sync_completed})
assert_receive(
- {:limited, "!room_id", "p1"},
+ {:polyjuice_client, :limited, {"!room_id", "p1"}},
1000
)
assert_receive(
- {:state, "!room_id",
- %{
- "content" => %{
- "membership" => "join"
- },
- "type" => "m.room.member",
- "state_key" => "@alice:example.org",
- "event_id" => "$join_event",
- "room_id" => "!room_id",
- "sender" => "@alice:example.org"
- }},
+ {:polyjuice_client, :state,
+ {"!room_id",
+ %{
+ "content" => %{
+ "membership" => "join"
+ },
+ "type" => "m.room.member",
+ "state_key" => "@alice:example.org",
+ "event_id" => "$join_event",
+ "room_id" => "!room_id",
+ "sender" => "@alice:example.org"
+ }}},
1000
)
assert_receive(
- {:message, "!room_id",
- %{
- "content" => %{
- "msgtype" => "m.text",
- "body" => "Hello World!"
- },
- "type" => "m.room.message",
- "event_id" => "$message_event",
- "room_id" => "!room_id",
- "sender" => "@alice:example.org"
- }},
+ {:polyjuice_client, :message,
+ {"!room_id",
+ %{
+ "content" => %{
+ "msgtype" => "m.text",
+ "body" => "Hello World!"
+ },
+ "type" => "m.room.message",
+ "event_id" => "$message_event",
+ "room_id" => "!room_id",
+ "sender" => "@alice:example.org"
+ }}},
1000
)
assert_receive(
- {:state, "!room_id",
- %{
- "content" => %{
- "membership" => "leave",
- "reason" => "Goodbye Cruel World!"
- },
- "type" => "m.room.member",
- "state_key" => "@alice:example.org",
- "event_id" => "$leave_event",
- "room_id" => "!room_id",
- "sender" => "@alice:example.org"
- }},
+ {:polyjuice_client, :state,
+ {"!room_id",
+ %{
+ "content" => %{
+ "membership" => "leave",
+ "reason" => "Goodbye Cruel World!"
+ },
+ "type" => "m.room.member",
+ "state_key" => "@alice:example.org",
+ "event_id" => "$leave_event",
+ "room_id" => "!room_id",
+ "sender" => "@alice:example.org"
+ }}},
1000
)
assert_receive(
- {:left, "!room_id"},
+ {:polyjuice_client, :left, {"!room_id"}},
1000
)
- Process.unlink(sync_pid)
- Process.exit(sync_pid, :kill)
-
Polyjuice.Client.stop(client)
:inets.stop(:httpd, httpd_pid)