From 4f786c60e18daf5e82b781b2b68db2e8aa884a42 Mon Sep 17 00:00:00 2001 From: technicalcapt Date: Thu, 12 Dec 2019 20:32:11 +0700 Subject: [PATCH] increase Task timeout and add test async --- lib/furlex.ex | 4 ++-- test/furlex/parser/facebook_test.exs | 6 +++++- test/furlex/parser/twitter_test.exs | 6 +++++- test/furlex_test.exs | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/furlex.ex b/lib/furlex.ex index 134fb83..56c9392 100644 --- a/lib/furlex.ex +++ b/lib/furlex.ex @@ -72,7 +72,7 @@ defmodule Furlex do defp fetch(url, opts) do fetch = Task.async(Fetcher, :fetch, [url, opts]) fetch_oembed = Task.async(Fetcher, :fetch_oembed, [url, opts]) - yield = Task.yield_many([fetch, fetch_oembed]) + yield = Task.yield_many([fetch, fetch_oembed], 10_000) with [fetch, fetch_oembed] <- yield, {_fetch, {:ok, {:ok, body, status_code}}} <- fetch, @@ -87,7 +87,7 @@ defmodule Furlex do parse = &Task.async(&1, :parse, [body]) tasks = Enum.map([Facebook, Twitter, JsonLD, HTML], parse) - with [facebook, twitter, json_ld, other] <- Task.yield_many(tasks), + with [facebook, twitter, json_ld, other] <- Task.yield_many(tasks, 18_000), {_facebook, {:ok, {:ok, facebook}}} <- facebook, {_twitter, {:ok, {:ok, twitter}}} <- twitter, {_json_ld, {:ok, {:ok, json_ld}}} <- json_ld, diff --git a/test/furlex/parser/facebook_test.exs b/test/furlex/parser/facebook_test.exs index 0c283cb..403abc8 100644 --- a/test/furlex/parser/facebook_test.exs +++ b/test/furlex/parser/facebook_test.exs @@ -1,10 +1,14 @@ defmodule Furlex.Parser.FacebookTest do - use ExUnit.Case + use ExUnit.Case, async: true alias Furlex.Parser.Facebook doctest Facebook + setup do + Application.put_env(:furlex, :group_keys?, true) + end + test "parses Facebook Open Graph" do html = " diff --git a/test/furlex/parser/twitter_test.exs b/test/furlex/parser/twitter_test.exs index adf2768..e770957 100644 --- a/test/furlex/parser/twitter_test.exs +++ b/test/furlex/parser/twitter_test.exs @@ -1,10 +1,14 @@ defmodule Furlex.Parser.TwitterTest do - use ExUnit.Case + use ExUnit.Case, async: true alias Furlex.Parser.Twitter doctest Twitter + setup do + Application.put_env(:furlex, :group_keys?, true) + end + test "parses Twitter Cards" do html = " diff --git a/test/furlex_test.exs b/test/furlex_test.exs index a89c91a..6666471 100644 --- a/test/furlex_test.exs +++ b/test/furlex_test.exs @@ -1,5 +1,5 @@ defmodule FurlexTest do - use ExUnit.Case + use ExUnit.Case, async: true setup do bypass = Bypass.open()