diff --git a/mix.exs b/mix.exs index 86fa952..f3d3c84 100644 --- a/mix.exs +++ b/mix.exs @@ -12,7 +12,7 @@ defmodule Hunter.Mixfile do description: "Elixir client for Mastodon, a GNU social-compatible micro-blogging service", build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, - elixirc_paths: elixirc_paths(Mix.env()), + elixirc_paths: ["lib"], deps: deps() ] end @@ -30,7 +30,8 @@ defmodule Hunter.Mixfile do {:httpoison, "~> 1.5"}, {:poison, "~> 4.0"}, {:ex_doc, "~> 0.14", only: :dev, runtime: false}, - {:dialyxir, "~> 1.0.0-rc.3", only: :dev, runtime: false} + {:dialyxir, "~> 1.0.0-rc.3", only: :dev, runtime: false}, + {:mox, "~> 0.5", only: :test} ] end @@ -53,8 +54,4 @@ defmodule Hunter.Mixfile do main: "readme" ] end - - # Specifies which paths to compile per environment - defp elixirc_paths(:test), do: ["lib", "test/support"] - defp elixirc_paths(_), do: ["lib"] end diff --git a/mix.lock b/mix.lock index 4ae1355..a77e218 100644 --- a/mix.lock +++ b/mix.lock @@ -11,6 +11,7 @@ "makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []}, + "mox": {:hex, :mox, "0.5.0", "c519b48407017a85f03407a9a4c4ceb7cc6dec5fe886b2241869fb2f08476f9e", [:mix], [], "hexpm"}, "nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, "poison": {:hex, :poison, "4.0.1", "bcb755a16fac91cad79bfe9fc3585bb07b9331e50cfe3420a24bcc2d735709ae", [:mix], [], "hexpm"}, diff --git a/test/fixtures/account.json b/test/fixtures/account.json deleted file mode 100644 index e2ffd29..0000000 --- a/test/fixtures/account.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id": 8039, - "username": "milmazz", - "acct": "milmazz", - "display_name": "Milton Mazzarri", - "locked": false, - "created_at": "2017-04-06T17:43:55.325Z", - "followers_count": 4, - "following_count": 4, - "statuses_count": 3, - "note": "", - "url": "https://social.lou.lt/@milmazz", - "avatar": "https://social.lou.lt/avatars/original/missing.png", - "avatar_static": "https://social.lou.lt/avatars/original/missing.png", - "header": "https://social.lou.lt/headers/original/missing.png", - "header_static": "https://social.lou.lt/headers/original/missing.png" -} diff --git a/test/fixtures/card_by_status.json b/test/fixtures/card_by_status.json deleted file mode 100644 index c870a0f..0000000 --- a/test/fixtures/card_by_status.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "url": "https://github.com/milmazz/hunter", - "title": "milmazz/hunter", - "image": "https://social.lou.lt/system/preview_cards/images/000/000/378/original/34700?1491626499", - "description": "hunter - A Elixir client for Mastodon, a GNU Social compatible micro-blogging service" -} diff --git a/test/fixtures/create_app.json b/test/fixtures/create_app.json deleted file mode 100644 index ec64ff2..0000000 --- a/test/fixtures/create_app.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "client_id": "1234567890", - "client_secret": "1234567890", - "id": 1234 -} diff --git a/test/fixtures/favourite.json b/test/fixtures/favourite.json deleted file mode 100644 index 8dc5425..0000000 --- a/test/fixtures/favourite.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "visibility": "public", - "url": "https://social.lou.lt/@FriendlyPootis/442", - "uri": "tag:social.lou.lt,2017-04-03:objectId=442:objectType=Status", - "tags": [], - "spoiler_text": "", - "sensitive": false, - "reblogs_count": 4, - "reblogged": false, - "reblog": null, - "mentions": [], - "media_attachments": [], - "in_reply_to_id": null, - "in_reply_to_account_id": null, - "id": 442, - "favourites_count": 5, - "favourited": true, - "created_at": "2017-04-03T16:22:04.286Z", - "content": "

les gens pensez à migrer d'instance pour en aller sur une moins chargée tant que vous pouvez, plus vous attendrez plus vous aurez la flemme

", - "application": { - "id": null, - "client_secret": null, - "client_id": null - }, - "account": { - "username": "FriendlyPootis", - "url": "https://social.lou.lt/@FriendlyPootis", - "statuses_count": 253, - "note": "fermé comme un carré, Vladimir Pootin sur YT (https://www.youtube.com/VladimirPootin)", - "locked": false, - "id": 34, - "header": "https://social.lou.lt/system/accounts/headers/000/000/034/original/b009ddb5a8ce41c1.jpg?1491228302", - "following_count": 53, - "followers_count": 62, - "display_name": "FriendlyPootis 🚉", - "created_at": "2017-04-03T13:50:06.485Z", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/000/034/original/565da0399c2c26cf.jpg?1491228302", - "acct": "FriendlyPootis" - } -} diff --git a/test/fixtures/favourited_by.json b/test/fixtures/favourited_by.json deleted file mode 100644 index 10b13d6..0000000 --- a/test/fixtures/favourited_by.json +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "id": 2286, - "username": "marxistvegan", - "acct": "marxistvegan", - "display_name": "stephen 🌹✪", - "locked": false, - "created_at": "2017-04-12T13:21:32.932Z", - "followers_count": 45, - "following_count": 62, - "statuses_count": 65, - "note": "Luxemburgist. Organizer in the labor & social movements. Co-host https://cyberunions.org podcast, member of https://glocal.coop. Pronoun he/him #AntiFa #marxist", - "url": "https://soc.ialis.me/@marxistvegan", - "avatar": "https://pictor.ialis.me/accounts/avatars/000/002/286/original/a7154cd28f490be2.jpeg?1492003901", - "avatar_static": "https://pictor.ialis.me/accounts/avatars/000/002/286/original/a7154cd28f490be2.jpeg?1492003901", - "header": "https://pictor.ialis.me/accounts/headers/000/002/286/original/b0457c9d6168b53e.png?1492080325", - "header_static": "https://pictor.ialis.me/accounts/headers/000/002/286/original/b0457c9d6168b53e.png?1492080325" - }, - { - "id": 1, - "username": "href", - "acct": "href", - "display_name": "href", - "locked": false, - "created_at": "2017-04-09T12:19:29.077Z", - "followers_count": 132, - "following_count": 198, - "statuses_count": 418, - "note": "cybermenace & mauvaise influence. #freebsd, #erlang, #elixir. #fr & #en.\r\n\r\nhttp://href.rocks - https://random.sh\r\n\r\nhttps://soc.ialis.me admin", - "url": "https://soc.ialis.me/@href", - "avatar": "https://pictor.ialis.me/accounts/avatars/000/000/001/original/42fe522de966bd8a.jpg?1491741513", - "avatar_static": "https://pictor.ialis.me/accounts/avatars/000/000/001/original/42fe522de966bd8a.jpg?1491741513", - "header": "https://pictor.ialis.me/accounts/headers/000/000/001/original/53b5cb6b4bb97932.jpg?1491745462", - "header_static": "https://pictor.ialis.me/accounts/headers/000/000/001/original/53b5cb6b4bb97932.jpg?1491745462" - } -] diff --git a/test/fixtures/favourites.json b/test/fixtures/favourites.json deleted file mode 100644 index 9ca21ea..0000000 --- a/test/fixtures/favourites.json +++ /dev/null @@ -1,38 +0,0 @@ -[ - { - "visibility": "public", - "url": "https://mstdn.io/users/paperswelove/updates/19905", - "uri": "tag:mstdn.io,2017-04-16:objectId=421573:objectType=Status", - "tags": [], - "spoiler_text": "Distributed Systems Paper", - "sensitive": false, - "reblogs_count": 0, - "reblogged": null, - "reblog": null, - "mentions": [], - "media_attachments": [], - "in_reply_to_id": null, - "in_reply_to_account_id": null, - "id": 376262, - "favourites_count": 0, - "favourited": true, - "created_at": "2017-04-16T15:32:24.000Z", - "content": "

Impossibility of Distributed Consensus with One Faulty
Process - Fischer, Lynch, Paterson

PDF: https://groups.csail.mit.edu/tds/papers/Lynch/jacm85.pdf

The consensus problem involves an asynchronous system of processes, some of which may be unreliable. The problem is for the reliable processes to agree on a binary value. In this paper, it is shown that every protocol for this problem has the possibility of nontermination, even with only one faulty process.

", - "application": null, - "account": { - "username": "paperswelove", - "url": "https://mstdn.io/@paperswelove", - "statuses_count": 20, - "note": "Building Bridges Between Academia and Industry\n\nhttp://paperswelove.org\nhttp://pwlconf.org", - "locked": false, - "id": 7126, - "header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258", - "following_count": 3, - "followers_count": 2, - "display_name": "Papers We Love", - "created_at": "2017-04-06T13:44:18.281Z", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "acct": "paperswelove@mstdn.io" - } - } -] diff --git a/test/fixtures/follow_by_uri.json b/test/fixtures/follow_by_uri.json deleted file mode 100644 index 9ef261a..0000000 --- a/test/fixtures/follow_by_uri.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "acct": "paperswelove@mstdn.io", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "created_at": "2017-04-06T13:44:18.281Z", - "display_name": "Papers We Love", - "followers_count": 1, - "following_count": 0, - "header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258", - "id": 7126, - "locked": false, - "note": "Building Bridges Between Academia and Industry\r\n\r\nhttp://paperswelove.org\r\nhttp://pwlconf.org", - "statuses_count": 1, - "url": "https://mstdn.io/@paperswelove", - "username": "paperswelove" -} \ No newline at end of file diff --git a/test/fixtures/followers.json b/test/fixtures/followers.json deleted file mode 100644 index 59eba92..0000000 --- a/test/fixtures/followers.json +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "id": 14825, - "username": "kadaba", - "acct": "kadaba@lavraievie.social", - "display_name": "Kadaba ✅", - "locked": false, - "created_at": "2017-04-10T15:53:45.161Z", - "followers_count": 1, - "following_count": 2, - "statuses_count": 25, - "note": "¡Cagando...! Digo: ¡¡¡...Cargando...!!! Debugging with Prozac. =JDK= ⠠⠵", - "url": "https://lavraievie.social/@kadaba", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/014/825/original/2acce7800f6d0366.jpeg?1491839628", - "avatar_static": "https://social.lou.lt/system/accounts/avatars/000/014/825/original/2acce7800f6d0366.jpeg?1491839628", - "header": "https://social.lou.lt/system/accounts/headers/000/014/825/original/missing.png?1491839631", - "header_static": "https://social.lou.lt/system/accounts/headers/000/014/825/original/missing.png?1491839631" - }, - { - "id": 7126, - "username": "paperswelove", - "acct": "paperswelove@mstdn.io", - "display_name": "Papers We Love", - "locked": false, - "created_at": "2017-04-06T13:44:18.281Z", - "followers_count": 2, - "following_count": 3, - "statuses_count": 16, - "note": "Building Bridges Between Academia and Industry\n\nhttp://paperswelove.org\nhttp://pwlconf.org", - "url": "https://mstdn.io/@paperswelove", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "avatar_static": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258", - "header_static": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258" - }, - { - "id": 8518, - "username": "atmantree", - "acct": "atmantree@mastodon.club", - "display_name": "Carlos Gustavo Ruiz", - "locked": false, - "created_at": "2017-04-06T20:07:57.119Z", - "followers_count": 2, - "following_count": 2, - "statuses_count": 0, - "note": "Programmer, Pythonista, Web Creature, Blogger, C++ and Haskell Fan. Never stop learning, because life never stops teaching.", - "url": "https://mastodon.club/@atmantree", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/008/518/original/7715529d4ceb4554.jpg?1491509276", - "avatar_static": "https://social.lou.lt/system/accounts/avatars/000/008/518/original/7715529d4ceb4554.jpg?1491509276", - "header": "https://social.lou.lt/system/accounts/headers/000/008/518/original/394f31473de7c64a.png?1491509277", - "header_static": "https://social.lou.lt/system/accounts/headers/000/008/518/original/394f31473de7c64a.png?1491509277" - }, - { - "id": 4682, - "username": "pankas87", - "acct": "pankas87", - "display_name": "Leonardo Graterol", - "locked": false, - "created_at": "2017-04-05T21:22:13.280Z", - "followers_count": 18, - "following_count": 20, - "statuses_count": 37, - "note": "I trade developing services for currency. Ruby fan, PHP mercenary, getting mind fucked by Scala. Venezuelan living in Chile\r\n\r\nLanguages: Spanish and English", - "url": "https://social.lou.lt/@pankas87", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/004/682/original/7a5fc3a6f54c833e.jpg?1491428029", - "avatar_static": "https://social.lou.lt/system/accounts/avatars/000/004/682/original/7a5fc3a6f54c833e.jpg?1491428029", - "header": "https://social.lou.lt/headers/original/missing.png", - "header_static": "https://social.lou.lt/headers/original/missing.png" - } -] \ No newline at end of file diff --git a/test/fixtures/following.json b/test/fixtures/following.json deleted file mode 100644 index de644c5..0000000 --- a/test/fixtures/following.json +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "id": 7126, - "username": "paperswelove", - "acct": "paperswelove@mstdn.io", - "display_name": "Papers We Love", - "locked": false, - "created_at": "2017-04-06T13:44:18.281Z", - "followers_count": 2, - "following_count": 3, - "statuses_count": 16, - "note": "Building Bridges Between Academia and Industry\n\nhttp://paperswelove.org\nhttp://pwlconf.org", - "url": "https://mstdn.io/@paperswelove", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "avatar_static": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258", - "header_static": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258" - }, - { - "id": 8518, - "username": "atmantree", - "acct": "atmantree@mastodon.club", - "display_name": "Carlos Gustavo Ruiz", - "locked": false, - "created_at": "2017-04-06T20:07:57.119Z", - "followers_count": 2, - "following_count": 2, - "statuses_count": 0, - "note": "Programmer, Pythonista, Web Creature, Blogger, C++ and Haskell Fan. Never stop learning, because life never stops teaching.", - "url": "https://mastodon.club/@atmantree", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/008/518/original/7715529d4ceb4554.jpg?1491509276", - "avatar_static": "https://social.lou.lt/system/accounts/avatars/000/008/518/original/7715529d4ceb4554.jpg?1491509276", - "header": "https://social.lou.lt/system/accounts/headers/000/008/518/original/394f31473de7c64a.png?1491509277", - "header_static": "https://social.lou.lt/system/accounts/headers/000/008/518/original/394f31473de7c64a.png?1491509277" - }, - { - "id": 4682, - "username": "pankas87", - "acct": "pankas87", - "display_name": "Leonardo Graterol", - "locked": false, - "created_at": "2017-04-05T21:22:13.280Z", - "followers_count": 18, - "following_count": 20, - "statuses_count": 37, - "note": "I trade developing services for currency. Ruby fan, PHP mercenary, getting mind fucked by Scala. Venezuelan living in Chile\r\n\r\nLanguages: Spanish and English", - "url": "https://social.lou.lt/@pankas87", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/004/682/original/7a5fc3a6f54c833e.jpg?1491428029", - "avatar_static": "https://social.lou.lt/system/accounts/avatars/000/004/682/original/7a5fc3a6f54c833e.jpg?1491428029", - "header": "https://social.lou.lt/headers/original/missing.png", - "header_static": "https://social.lou.lt/headers/original/missing.png" - }, - { - "id": 7899, - "username": "sebasmagri", - "acct": "sebasmagri@mastodon.cloud", - "display_name": "Sebastián Ramírez Magrí", - "locked": false, - "created_at": "2017-04-06T17:07:38.912Z", - "followers_count": 2, - "following_count": 1, - "statuses_count": 7, - "note": "", - "url": "https://mastodon.cloud/@sebasmagri", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/007/899/original/19b4d8c1e9d4e68a.jpg?1491498458", - "avatar_static": "https://social.lou.lt/system/accounts/avatars/000/007/899/original/19b4d8c1e9d4e68a.jpg?1491498458", - "header": "https://social.lou.lt/system/accounts/headers/000/007/899/original/missing.png?1491498458", - "header_static": "https://social.lou.lt/system/accounts/headers/000/007/899/original/missing.png?1491498458" - } -] \ No newline at end of file diff --git a/test/fixtures/hashtag_timeline.json b/test/fixtures/hashtag_timeline.json deleted file mode 100644 index 949b2b1..0000000 --- a/test/fixtures/hashtag_timeline.json +++ /dev/null @@ -1,60 +0,0 @@ -[ - { - "visibility": "public", - "url": "https://mstdn.io/users/paperswelove/updates/9954", - "uri": "tag:mstdn.io,2017-04-10:objectId=171105:objectType=Status", - "tags": [ - { - "url": "https://social.lou.lt/tags/paperswelove", - "name": "paperswelove" - }, - { - "url": "https://social.lou.lt/tags/compsci", - "name": "compsci" - }, - { - "url": "https://social.lou.lt/tags/garbagecollection", - "name": "garbagecollection" - } - ], - "spoiler_text": "", - "sensitive": false, - "reblogs_count": 0, - "reblogged": null, - "reblog": null, - "mentions": [], - "media_attachments": [ - { - "url": "https://social.lou.lt/system/media_attachments/files/000/010/284/original/b0432b95264e141c.png?1491824449", - "type": "image", - "text_url": null, - "remote_url": "https://mstdn.io/system/media_attachments/files/000/009/562/original/b0432b95264e141c.png", - "preview_url": "https://social.lou.lt/system/media_attachments/files/000/010/284/small/b0432b95264e141c.png?1491824449", - "id": 10284 - } - ], - "in_reply_to_id": null, - "in_reply_to_account_id": null, - "id": 186397, - "favourites_count": 0, - "favourited": null, - "created_at": "2017-04-10T11:40:45.000Z", - "content": "

One Pass Real-Time Generational Mark-Sweep Garbage Collection - Armstrong, Virding

Link: http://buff.ly/2pdh7iS

In this paper we present a simple scheme for reclaiming data for such language classes with a single pass mark-sweep collector. We also show how the simple scheme can be modified so that the collection can be done in an incremental manner (making it suitable for real-time collection).

#garbagecollection #compsci #paperswelove

https://mstdn.io/media/u03CNEJZho1pvTR3q6Y

", - "application": null, - "account": { - "username": "paperswelove", - "url": "https://mstdn.io/@paperswelove", - "statuses_count": 8, - "note": "Building Bridges Between Academia and Industry\n\nhttp://paperswelove.org\nhttp://pwlconf.org", - "locked": false, - "id": 7126, - "header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258", - "following_count": 1, - "followers_count": 1, - "display_name": "Papers We Love", - "created_at": "2017-04-06T13:44:18.281Z", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "acct": "paperswelove@mstdn.io" - } - } -] diff --git a/test/fixtures/home_timeline.json b/test/fixtures/home_timeline.json deleted file mode 100644 index 949b2b1..0000000 --- a/test/fixtures/home_timeline.json +++ /dev/null @@ -1,60 +0,0 @@ -[ - { - "visibility": "public", - "url": "https://mstdn.io/users/paperswelove/updates/9954", - "uri": "tag:mstdn.io,2017-04-10:objectId=171105:objectType=Status", - "tags": [ - { - "url": "https://social.lou.lt/tags/paperswelove", - "name": "paperswelove" - }, - { - "url": "https://social.lou.lt/tags/compsci", - "name": "compsci" - }, - { - "url": "https://social.lou.lt/tags/garbagecollection", - "name": "garbagecollection" - } - ], - "spoiler_text": "", - "sensitive": false, - "reblogs_count": 0, - "reblogged": null, - "reblog": null, - "mentions": [], - "media_attachments": [ - { - "url": "https://social.lou.lt/system/media_attachments/files/000/010/284/original/b0432b95264e141c.png?1491824449", - "type": "image", - "text_url": null, - "remote_url": "https://mstdn.io/system/media_attachments/files/000/009/562/original/b0432b95264e141c.png", - "preview_url": "https://social.lou.lt/system/media_attachments/files/000/010/284/small/b0432b95264e141c.png?1491824449", - "id": 10284 - } - ], - "in_reply_to_id": null, - "in_reply_to_account_id": null, - "id": 186397, - "favourites_count": 0, - "favourited": null, - "created_at": "2017-04-10T11:40:45.000Z", - "content": "

One Pass Real-Time Generational Mark-Sweep Garbage Collection - Armstrong, Virding

Link: http://buff.ly/2pdh7iS

In this paper we present a simple scheme for reclaiming data for such language classes with a single pass mark-sweep collector. We also show how the simple scheme can be modified so that the collection can be done in an incremental manner (making it suitable for real-time collection).

#garbagecollection #compsci #paperswelove

https://mstdn.io/media/u03CNEJZho1pvTR3q6Y

", - "application": null, - "account": { - "username": "paperswelove", - "url": "https://mstdn.io/@paperswelove", - "statuses_count": 8, - "note": "Building Bridges Between Academia and Industry\n\nhttp://paperswelove.org\nhttp://pwlconf.org", - "locked": false, - "id": 7126, - "header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258", - "following_count": 1, - "followers_count": 1, - "display_name": "Papers We Love", - "created_at": "2017-04-06T13:44:18.281Z", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "acct": "paperswelove@mstdn.io" - } - } -] diff --git a/test/fixtures/instance_info.json b/test/fixtures/instance_info.json deleted file mode 100644 index 858d5b3..0000000 --- a/test/fixtures/instance_info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "uri": "social.lou.lt", - "title": "Loultstodon", - "email": "maxime+mastodon@melinon.fr", - "description": "Mostly French instance - Read full description for rules." -} diff --git a/test/fixtures/mute.json b/test/fixtures/mute.json deleted file mode 100644 index 3d91e66..0000000 --- a/test/fixtures/mute.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "requested": false, - "muting": true, - "following": true, - "followed_by": false, - "blocking": false -} diff --git a/test/fixtures/notification.json b/test/fixtures/notification.json deleted file mode 100644 index 8f0268b..0000000 --- a/test/fixtures/notification.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "type": "follow", - "status": null, - "id": 17476, - "created_at": "2017-04-08T12:15:53.467Z", - "account": { - "username": "paperswelove", - "url": "https://mstdn.io/@paperswelove", - "statuses_count": 8, - "note": "Building Bridges Between Academia and Industry\n\nhttp://paperswelove.org\nhttp://pwlconf.org", - "locked": false, - "id": 7126, - "header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258", - "following_count": 1, - "followers_count": 1, - "display_name": "Papers We Love", - "created_at": "2017-04-06T13:44:18.281Z", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "acct": "paperswelove@mstdn.io" - } -} diff --git a/test/fixtures/notifications.json b/test/fixtures/notifications.json deleted file mode 100644 index b639b88..0000000 --- a/test/fixtures/notifications.json +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "type": "follow", - "status": null, - "id": 17476, - "created_at": "2017-04-08T12:15:53.467Z", - "account": { - "username": "paperswelove", - "url": "https://mstdn.io/@paperswelove", - "statuses_count": 8, - "note": "Building Bridges Between Academia and Industry\n\nhttp://paperswelove.org\nhttp://pwlconf.org", - "locked": false, - "id": 7126, - "header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258", - "following_count": 1, - "followers_count": 1, - "display_name": "Papers We Love", - "created_at": "2017-04-06T13:44:18.281Z", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "acct": "paperswelove@mstdn.io" - } - } -] diff --git a/test/fixtures/public_timeline.json b/test/fixtures/public_timeline.json deleted file mode 100644 index 949b2b1..0000000 --- a/test/fixtures/public_timeline.json +++ /dev/null @@ -1,60 +0,0 @@ -[ - { - "visibility": "public", - "url": "https://mstdn.io/users/paperswelove/updates/9954", - "uri": "tag:mstdn.io,2017-04-10:objectId=171105:objectType=Status", - "tags": [ - { - "url": "https://social.lou.lt/tags/paperswelove", - "name": "paperswelove" - }, - { - "url": "https://social.lou.lt/tags/compsci", - "name": "compsci" - }, - { - "url": "https://social.lou.lt/tags/garbagecollection", - "name": "garbagecollection" - } - ], - "spoiler_text": "", - "sensitive": false, - "reblogs_count": 0, - "reblogged": null, - "reblog": null, - "mentions": [], - "media_attachments": [ - { - "url": "https://social.lou.lt/system/media_attachments/files/000/010/284/original/b0432b95264e141c.png?1491824449", - "type": "image", - "text_url": null, - "remote_url": "https://mstdn.io/system/media_attachments/files/000/009/562/original/b0432b95264e141c.png", - "preview_url": "https://social.lou.lt/system/media_attachments/files/000/010/284/small/b0432b95264e141c.png?1491824449", - "id": 10284 - } - ], - "in_reply_to_id": null, - "in_reply_to_account_id": null, - "id": 186397, - "favourites_count": 0, - "favourited": null, - "created_at": "2017-04-10T11:40:45.000Z", - "content": "

One Pass Real-Time Generational Mark-Sweep Garbage Collection - Armstrong, Virding

Link: http://buff.ly/2pdh7iS

In this paper we present a simple scheme for reclaiming data for such language classes with a single pass mark-sweep collector. We also show how the simple scheme can be modified so that the collection can be done in an incremental manner (making it suitable for real-time collection).

#garbagecollection #compsci #paperswelove

https://mstdn.io/media/u03CNEJZho1pvTR3q6Y

", - "application": null, - "account": { - "username": "paperswelove", - "url": "https://mstdn.io/@paperswelove", - "statuses_count": 8, - "note": "Building Bridges Between Academia and Industry\n\nhttp://paperswelove.org\nhttp://pwlconf.org", - "locked": false, - "id": 7126, - "header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258", - "following_count": 1, - "followers_count": 1, - "display_name": "Papers We Love", - "created_at": "2017-04-06T13:44:18.281Z", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "acct": "paperswelove@mstdn.io" - } - } -] diff --git a/test/fixtures/reblogged_by.json b/test/fixtures/reblogged_by.json deleted file mode 100644 index e44cddb..0000000 --- a/test/fixtures/reblogged_by.json +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "id": 970, - "username": "maliciarogue", - "acct": "maliciarogue@mastodon.social", - "display_name": "R ✅", - "locked": false, - "created_at": "2017-04-10T14:30:57.949Z", - "followers_count": 3, - "following_count": 2, - "statuses_count": 156, - "note": "I troll, therefore I am. Writer; OSINT & sec analyst; I do risk & crisis mngmnt so u don't have to.Polylingual bookworm. I toot 4 chocolate /!\\Parental advisory", - "url": "https://mastodon.social/@maliciarogue", - "avatar": "https://pictor.ialis.me/accounts/avatars/000/000/970/original/d5a601a0133d75c1.jpg?1491834658", - "avatar_static": "https://pictor.ialis.me/accounts/avatars/000/000/970/original/d5a601a0133d75c1.jpg?1491834658", - "header": "/headers/original/missing.png", - "header_static": "/headers/original/missing.png" - }, - { - "id": 2495, - "username": "hecate", - "acct": "hecate", - "display_name": "Hecatée Irssiainen", - "locked": false, - "created_at": "2017-04-12T20:05:42.369Z", - "followers_count": 5, - "following_count": 6, - "statuses_count": 9, - "note": "Cyber-postrock technoqueer. I go by she/her, and it's usually with your mum.", - "url": "https://soc.ialis.me/@hecate", - "avatar": "https://pictor.ialis.me/accounts/avatars/000/002/495/original/7c78b503266e4bdf.png?1492027924", - "avatar_static": "https://pictor.ialis.me/accounts/avatars/000/002/495/original/7c78b503266e4bdf.png?1492027924", - "header": "https://pictor.ialis.me/accounts/headers/000/002/495/original/a1f76633a274cb61.jpg?1492027924", - "header_static": "https://pictor.ialis.me/accounts/headers/000/002/495/original/a1f76633a274cb61.jpg?1492027924" - } -] diff --git a/test/fixtures/status.json b/test/fixtures/status.json deleted file mode 100644 index 27a6e6f..0000000 --- a/test/fixtures/status.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "visibility": "public", - "url": "https://mstdn.io/users/paperswelove/updates/19905", - "uri": "tag:mstdn.io,2017-04-16:objectId=421573:objectType=Status", - "tags": [], - "spoiler_text": "Distributed Systems Paper", - "sensitive": false, - "reblogs_count": 0, - "reblogged": false, - "reblog": null, - "mentions": [], - "media_attachments": [], - "in_reply_to_id": null, - "in_reply_to_account_id": null, - "id": 376262, - "favourites_count": 0, - "favourited": true, - "created_at": "2017-04-16T15:32:24.000Z", - "content": "

Impossibility of Distributed Consensus with One Faulty
Process - Fischer, Lynch, Paterson

PDF: https://groups.csail.mit.edu/tds/papers/Lynch/jacm85.pdf

The consensus problem involves an asynchronous system of processes, some of which may be unreliable. The problem is for the reliable processes to agree on a binary value. In this paper, it is shown that every protocol for this problem has the possibility of nontermination, even with only one faulty process.

", - "application": null, - "account": { - "username": "paperswelove", - "url": "https://mstdn.io/@paperswelove", - "statuses_count": 20, - "note": "Building Bridges Between Academia and Industry\n\nhttp://paperswelove.org\nhttp://pwlconf.org", - "locked": false, - "id": 7126, - "header_static": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258", - "header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258", - "following_count": 3, - "followers_count": 2, - "display_name": "Papers We Love", - "created_at": "2017-04-06T13:44:18.281Z", - "avatar_static": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258", - "acct": "paperswelove@mstdn.io" - } -} diff --git a/test/fixtures/statuses.json b/test/fixtures/statuses.json deleted file mode 100644 index 85560a0..0000000 --- a/test/fixtures/statuses.json +++ /dev/null @@ -1,134 +0,0 @@ -[ - { - "visibility": "public", - "url": "https://social.lou.lt/@milmazz/212703", - "uri": "tag:social.lou.lt,2017-04-11:objectId=212703:objectType=Status", - "tags": [], - "spoiler_text": "", - "sensitive": false, - "reblogs_count": 1, - "reblogged": null, - "reblog": null, - "mentions": [], - "media_attachments": [], - "in_reply_to_id": null, - "in_reply_to_account_id": null, - "id": 212703, - "favourites_count": 1, - "favourited": null, - "created_at": "2017-04-11T04:55:55.778Z", - "content": "

New release: hunter (0.3.0): Elixir client for Mastodon, a GNU social-compatible micro-blogging service

https://hex.pm/packages/hunter

", - "application": { - "id": null, - "client_secret": null, - "client_id": null - }, - "account": { - "username": "milmazz", - "url": "https://social.lou.lt/@milmazz", - "statuses_count": 3, - "note": "", - "locked": false, - "id": 8039, - "header": "https://social.lou.lt/headers/original/missing.png", - "following_count": 4, - "followers_count": 4, - "display_name": "Milton Mazzarri", - "created_at": "2017-04-06T17:43:55.325Z", - "avatar": "https://social.lou.lt/avatars/original/missing.png", - "acct": "milmazz" - } - }, - { - "visibility": "public", - "url": "https://social.lou.lt/@milmazz/118635", - "uri": "tag:social.lou.lt,2017-04-08:objectId=118635:objectType=Status", - "tags": [ - { - "url": "https://social.lou.lt/tags/myelixirstatus", - "name": "myelixirstatus" - } - ], - "spoiler_text": "", - "sensitive": null, - "reblogs_count": 0, - "reblogged": null, - "reblog": null, - "mentions": [], - "media_attachments": [], - "in_reply_to_id": null, - "in_reply_to_account_id": null, - "id": 118635, - "favourites_count": 1, - "favourited": null, - "created_at": "2017-04-08T04:41:38.643Z", - "content": "

Hunter is a Elixir client for Mastodon: https://github.com/milmazz/hunter #myelixirstatus

", - "application": { - "id": null, - "client_secret": null, - "client_id": null - }, - "account": { - "username": "milmazz", - "url": "https://social.lou.lt/@milmazz", - "statuses_count": 3, - "note": "", - "locked": false, - "id": 8039, - "header": "https://social.lou.lt/headers/original/missing.png", - "following_count": 4, - "followers_count": 4, - "display_name": "Milton Mazzarri", - "created_at": "2017-04-06T17:43:55.325Z", - "avatar": "https://social.lou.lt/avatars/original/missing.png", - "acct": "milmazz" - } - }, - { - "visibility": "public", - "url": "https://social.lou.lt/@milmazz/59144", - "uri": "tag:social.lou.lt,2017-04-06:objectId=59144:objectType=Status", - "tags": [], - "spoiler_text": "", - "sensitive": false, - "reblogs_count": 0, - "reblogged": null, - "reblog": null, - "mentions": [ - { - "username": "Shutsumon", - "url": "http://tootplanet.space/@Shutsumon", - "id": 7742, - "acct": "Shutsumon@tootplanet.space" - } - ], - "media_attachments": [], - "in_reply_to_id": 59042, - "in_reply_to_account_id": 7742, - "id": 59144, - "favourites_count": 0, - "favourited": null, - "created_at": "2017-04-06T18:28:59.392Z", - "content": "

@Shutsumon You should read "How to design programs" book http://htdp.org

", - "application": { - "id": null, - "client_secret": null, - "client_id": null - }, - "account": { - "username": "milmazz", - "url": "https://social.lou.lt/@milmazz", - "statuses_count": 3, - "note": "", - "locked": false, - "id": 8039, - "header": "https://social.lou.lt/headers/original/missing.png", - "following_count": 4, - "followers_count": 4, - "display_name": "Milton Mazzarri", - "created_at": "2017-04-06T17:43:55.325Z", - "avatar": "https://social.lou.lt/avatars/original/missing.png", - "acct": "milmazz" - } - } -] diff --git a/test/fixtures/unfavourite.json b/test/fixtures/unfavourite.json deleted file mode 100644 index 8dc5425..0000000 --- a/test/fixtures/unfavourite.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "visibility": "public", - "url": "https://social.lou.lt/@FriendlyPootis/442", - "uri": "tag:social.lou.lt,2017-04-03:objectId=442:objectType=Status", - "tags": [], - "spoiler_text": "", - "sensitive": false, - "reblogs_count": 4, - "reblogged": false, - "reblog": null, - "mentions": [], - "media_attachments": [], - "in_reply_to_id": null, - "in_reply_to_account_id": null, - "id": 442, - "favourites_count": 5, - "favourited": true, - "created_at": "2017-04-03T16:22:04.286Z", - "content": "

les gens pensez à migrer d'instance pour en aller sur une moins chargée tant que vous pouvez, plus vous attendrez plus vous aurez la flemme

", - "application": { - "id": null, - "client_secret": null, - "client_id": null - }, - "account": { - "username": "FriendlyPootis", - "url": "https://social.lou.lt/@FriendlyPootis", - "statuses_count": 253, - "note": "fermé comme un carré, Vladimir Pootin sur YT (https://www.youtube.com/VladimirPootin)", - "locked": false, - "id": 34, - "header": "https://social.lou.lt/system/accounts/headers/000/000/034/original/b009ddb5a8ce41c1.jpg?1491228302", - "following_count": 53, - "followers_count": 62, - "display_name": "FriendlyPootis 🚉", - "created_at": "2017-04-03T13:50:06.485Z", - "avatar": "https://social.lou.lt/system/accounts/avatars/000/000/034/original/565da0399c2c26cf.jpg?1491228302", - "acct": "FriendlyPootis" - } -} diff --git a/test/fixtures/unmute.json b/test/fixtures/unmute.json deleted file mode 100644 index ff3df73..0000000 --- a/test/fixtures/unmute.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "requested": false, - "muting": false, - "following": true, - "followed_by": false, - "blocking": false -} diff --git a/test/fixtures/verify_credentials.json b/test/fixtures/verify_credentials.json deleted file mode 100644 index 8190201..0000000 --- a/test/fixtures/verify_credentials.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id": 8039, - "username": "milmazz", - "acct": "milmazz", - "display_name": "Milton Mazzarri", - "locked": false, - "created_at": "2017-04-06T17:43:55.325Z", - "followers_count": 4, - "following_count": 4, - "statuses_count": 3, - "note": "", - "url": "https://social.lou.lt/@milmazz", - "avatar": "https://social.lou.lt/avatars/original/missing.png", - "avatar_static": "https://social.lou.lt/avatars/original/missing.png", - "header": "https://social.lou.lt/headers/original/missing.png", - "header_static": "https://social.lou.lt/headers/original/missing.png" -} diff --git a/test/hunter/account_test.exs b/test/hunter/account_test.exs index d3d2953..1b373f2 100644 --- a/test/hunter/account_test.exs +++ b/test/hunter/account_test.exs @@ -1,33 +1,52 @@ defmodule Hunter.AccountTest do use ExUnit.Case, async: true - doctest Hunter.Account + + import Mox alias Hunter.Account - setup do - [conn: Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456")] + @conn Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456") + + setup :verify_on_exit! + + test "verify credentials" do + expect(Hunter.ApiMock, :verify_credentials, fn %Hunter.Client{} -> + %Account{username: "milmazz"} + end) + + assert %Account{username: "milmazz"} = Account.verify_credentials(@conn) end - test "verify credentials", %{conn: conn} do - assert %Account{username: "milmazz"} = Account.verify_credentials(conn) + test "returns an account" do + expect(Hunter.ApiMock, :account, fn %Hunter.Client{}, _id -> + %Account{username: "milmazz"} + end) + + assert %Account{username: "milmazz"} = Account.account(@conn, 8039) end - test "returns an account", %{conn: conn} do - assert %Account{username: "milmazz"} = Account.account(conn, 8039) + test "returns a collection of followers accounts" do + expect(Hunter.ApiMock, :followers, fn %Hunter.Client{}, _id, _opts -> + [%Account{username: "kadaba"}] + end) + + assert [%Account{username: "kadaba"} | _] = Account.followers(@conn, 8039) end - test "returns a collection of followers accounts", %{conn: conn} do - collection = Account.followers(conn, 8039) - assert %Account{username: "kadaba"} = List.first(collection) + test "returns a collection of following accounts" do + expect(Hunter.ApiMock, :following, fn %Hunter.Client{}, _id, _opts -> + [%Account{username: "paperswelove"}] + end) + + assert [%Account{username: "paperswelove"} | _] = Account.following(@conn, 8039) end - test "returns a collection of following accounts", %{conn: conn} do - collection = Account.following(conn, 8039) - assert %Account{username: "paperswelove"} = List.first(collection) - end + test "following a remote user" do + expect(Hunter.ApiMock, :follow_by_uri, fn %Hunter.Client{}, _id -> + %Account{username: "paperswelove"} + end) - test "following a remote user", %{conn: conn} do assert %Account{username: "paperswelove"} = - Account.follow_by_uri(conn, "paperswelove@mstdn.io") + Account.follow_by_uri(@conn, "paperswelove@mstdn.io") end end diff --git a/test/hunter/application_test.exs b/test/hunter/application_test.exs index 0fbcd8c..5ff06e1 100644 --- a/test/hunter/application_test.exs +++ b/test/hunter/application_test.exs @@ -1,4 +1,25 @@ defmodule Hunter.ApplicationTest do use ExUnit.Case, async: true - doctest Hunter.Application + + import Mox + + alias Hunter.Application + + setup :verify_on_exit! + + test "should allow to create an app" do + expect(Hunter.ApiMock, :create_app, fn _client, _redirect, _scopes, _website, _opts -> + %Application{client_id: "1234567890", client_secret: "1234567890", id: 1234} + end) + + assert %Application{client_id: "1234567890", client_secret: "1234567890", id: 1234} == + Application.create_app( + "hunter", + "urn:ietf:wg:oauth:2.0:oob", + ["read", "write", "follow"], + nil, + save?: false, + api_base_url: "https://example.com" + ) + end end diff --git a/test/hunter/card_test.exs b/test/hunter/card_test.exs index cecde1b..ed5a9bd 100644 --- a/test/hunter/card_test.exs +++ b/test/hunter/card_test.exs @@ -1,14 +1,18 @@ defmodule Hunter.CardTest do use ExUnit.Case, async: true - doctest Hunter.Card + + import Mox alias Hunter.Card - setup do - [conn: Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456")] - end + setup :verify_on_exit! - test "verify a card associated with a status", %{conn: conn} do + test "verify a card associated with a status" do + expect(Hunter.ApiMock, :card_by_status, fn _conn, _id -> + %Card{title: "milmazz/hunter"} + end) + + conn = Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456") assert %Card{title: "milmazz/hunter"} = Card.card_by_status(conn, 118_635) end end diff --git a/test/hunter/instance_test.exs b/test/hunter/instance_test.exs index 81bc9ff..29d7463 100644 --- a/test/hunter/instance_test.exs +++ b/test/hunter/instance_test.exs @@ -1,14 +1,18 @@ defmodule Hunter.InstanceTest do use ExUnit.Case, async: true - doctest Hunter.Instance + + import Mox alias Hunter.Instance - setup do - [conn: Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456")] - end + setup :verify_on_exit! - test "verify instance information", %{conn: conn} do + test "verify instance information" do + expect(Hunter.ApiMock, :instance_info, fn _conn -> + %Instance{uri: "social.lou.lt"} + end) + + conn = Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456") assert %Instance{uri: "social.lou.lt"} = Instance.instance_info(conn) end end diff --git a/test/hunter/notification_test.exs b/test/hunter/notification_test.exs index f09e4f6..d17030b 100644 --- a/test/hunter/notification_test.exs +++ b/test/hunter/notification_test.exs @@ -1,22 +1,31 @@ defmodule Hunter.NotificationTest do use ExUnit.Case, async: true - doctest Hunter.Notification - alias Hunter.Notification + import Mox - setup do - [conn: Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456")] + alias Hunter.{Account, Notification} + + @conn Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456") + + setup :verify_on_exit! + + test "fetch user's notifications" do + expect(Hunter.ApiMock, :notifications, fn _conn, _opts -> + [%Notification{account: %Account{username: "paperswelove"}, type: "follow"}] + end) + + [notification | _] = Notification.notifications(@conn) + assert "paperswelove" == notification.account.username + assert "follow" == notification.type end - test "fetch user's notifications", %{conn: conn} do - notifications = conn |> Notification.notifications() |> List.first() - assert "paperswelove" == notifications.account["username"] - assert "follow" == notifications.type - end + test "fetch a single notification" do + expect(Hunter.ApiMock, :notification, fn _conn, _id -> + %Notification{account: %Account{username: "paperswelove"}, type: "follow"} + end) - test "fetch a single notification", %{conn: conn} do - notification = Notification.notification(conn, 17_476) - assert "paperswelove" == notification.account["username"] + notification = Notification.notification(@conn, 17_476) + assert "paperswelove" == notification.account.username assert "follow" == notification.type end end diff --git a/test/hunter/status_test.exs b/test/hunter/status_test.exs index 8248de0..d2b6830 100644 --- a/test/hunter/status_test.exs +++ b/test/hunter/status_test.exs @@ -1,20 +1,27 @@ defmodule Hunter.StatusTest do use ExUnit.Case, async: true - doctest Hunter.Status + + import Mox alias Hunter.Status - setup do - [conn: Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456")] + @conn Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456") + + setup :verify_on_exit! + + test "home timeline should return a collection of statuses" do + expect(Hunter.ApiMock, :home_timeline, fn _conn, _opts -> + [%Hunter.Status{}] + end) + + assert [timeline | []] = Status.home_timeline(@conn, limit: 1) end - test "home timeline should return a collection of statuses", %{conn: conn} do - timeline = Status.home_timeline(conn, limit: 1) - assert Enum.count(timeline) == 1 - end + test "public time should return a collection of statuses" do + expect(Hunter.ApiMock, :public_timeline, fn _conn, _opts -> + [%Hunter.Status{}] + end) - test "public time should return a collection of statuses", %{conn: conn} do - timeline = Status.public_timeline(conn, limit: 1, local: true) - assert Enum.count(timeline) == 1 + assert [timeline | []] = Status.public_timeline(@conn, limit: 1, local: true) end end diff --git a/test/support/in_memory.ex b/test/support/in_memory.ex deleted file mode 100644 index 916c53e..0000000 --- a/test/support/in_memory.ex +++ /dev/null @@ -1,72 +0,0 @@ -defmodule Hunter.Api.InMemory do - @moduledoc """ - In-Memory Client (for testing purposes) - """ - - @behaviour Hunter.Api - - [ - %{name: :account, arity: 2, as: %Hunter.Account{}}, - %{name: :block, arity: 2, as: %Hunter.Relationship{}}, - %{name: :blocks, arity: 2, as: [%Hunter.Account{}]}, - %{name: :card_by_status, arity: 2, as: %Hunter.Card{}}, - %{name: :clear_notifications, arity: 1, as: %{}}, - %{name: :create_app, arity: 5, as: %Hunter.Application{}}, - %{name: :create_status, arity: 3, as: %Hunter.Status{}}, - %{name: :favourite, arity: 2, as: %Hunter.Status{}}, - %{name: :favourited_by, arity: 3, as: [%Hunter.Account{}]}, - %{name: :favourites, arity: 2, as: [%Hunter.Status{}]}, - %{name: :follow, arity: 2, as: %Hunter.Relationship{}}, - %{name: :follow_by_uri, arity: 2, as: %Hunter.Account{}}, - %{name: :follow_requests, arity: 2, as: [%Hunter.Account{}]}, - %{name: :followers, arity: 3, as: [%Hunter.Account{}]}, - %{name: :following, arity: 3, as: [%Hunter.Account{}]}, - %{name: :hashtag_timeline, arity: 3, as: [%Hunter.Status{}]}, - %{name: :home_timeline, arity: 2, as: [%Hunter.Status{}]}, - %{name: :instance_info, arity: 1, as: %Hunter.Instance{}}, - %{name: :log_in, arity: 4, as: %Hunter.Client{}}, - %{name: :mute, arity: 2, as: %Hunter.Relationship{}}, - %{name: :mutes, arity: 2, as: [%Hunter.Account{}]}, - %{name: :notification, arity: 2, as: %Hunter.Notification{}}, - %{name: :notifications, arity: 2, as: [%Hunter.Notification{}]}, - %{name: :public_timeline, arity: 2, as: [%Hunter.Status{}]}, - %{name: :reblog, arity: 2, as: %Hunter.Status{}}, - %{name: :reblogged_by, arity: 3, as: [%Hunter.Account{}]}, - %{name: :relationships, arity: 2, as: [%Hunter.Relationship{}]}, - %{name: :report, arity: 4, as: %Hunter.Report{}}, - %{name: :reports, arity: 1, as: [%Hunter.Report{}]}, - %{name: :search, arity: 3, as: %Hunter.Result{}}, - %{name: :search_account, arity: 2, as: [%Hunter.Account{}]}, - %{name: :status, arity: 2, as: %Hunter.Status{}}, - %{name: :status_context, arity: 2, as: %Hunter.Context{}}, - %{name: :statuses, arity: 3, as: [%Hunter.Status{}]}, - %{name: :unblock, arity: 2, as: %Hunter.Relationship{}}, - %{name: :unfavourite, arity: 2, as: %Hunter.Status{}}, - %{name: :unfollow, arity: 2, as: %Hunter.Relationship{}}, - %{name: :unmute, arity: 2, as: %Hunter.Relationship{}}, - %{name: :unreblog, arity: 2, as: %Hunter.Status{}}, - %{name: :update_credentials, arity: 2, as: %Hunter.Account{}}, - %{name: :upload_media, arity: 3, as: %Hunter.Attachment{}}, - %{name: :verify_credentials, arity: 1, as: %Hunter.Account{}} - ] - |> Enum.map(fn %{name: name, arity: arity, as: as} -> - params = for _ <- 1..arity, do: {:_, [], nil} - as = Macro.escape(as) - - def unquote(name)(unquote_splicing(params)) do - file = to_string(unquote(name)) - - "../fixtures/#{file}.json" - |> Path.expand(__DIR__) - |> File.read!() - |> Poison.decode!(as: unquote(as)) - end - end) - - def destroy_status(_, _), do: true - def follow_request_action(_, _, _), do: true - def blocked_domains(_, _), do: ["example.com"] - def block_domain(_, _), do: true - def unblock_domain(_, _), do: true - def clear_notification(_, _), do: true -end diff --git a/test/test_helper.exs b/test/test_helper.exs index 23b94a4..d695673 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,2 +1,3 @@ ExUnit.start() -Application.put_env(:hunter, :hunter_api, Hunter.Api.InMemory) +Mox.defmock(Hunter.ApiMock, for: Hunter.Api) +Application.put_env(:hunter, :hunter_api, Hunter.ApiMock)