diff options
Diffstat (limited to 'test/polyjuice/client')
-rw-r--r-- | test/polyjuice/client/media_test.exs | 3 | ||||
-rw-r--r-- | test/polyjuice/client/sync_test.exs | 121 |
2 files changed, 62 insertions, 62 deletions
diff --git a/test/polyjuice/client/media_test.exs b/test/polyjuice/client/media_test.exs index b4899ca..4c545ac 100644 --- a/test/polyjuice/client/media_test.exs +++ b/test/polyjuice/client/media_test.exs @@ -87,10 +87,11 @@ defmodule Polyjuice.Client.MediaTest 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.MediaTest.Httpd", access_token: "an_access_token", user_id: "@alice:example.org", + sync: false, test: true ) 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) |