Skip to content

Commit

Permalink
increase Task timeout and add test async
Browse files Browse the repository at this point in the history
  • Loading branch information
technicalcapt authored and neilberkman committed Dec 12, 2019
1 parent ef8a81c commit 4f786c6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/furlex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion test/furlex/parser/facebook_test.exs
Original file line number Diff line number Diff line change
@@ -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 =
"<html><head><meta property=\"og:url\" " <>
Expand Down
6 changes: 5 additions & 1 deletion test/furlex/parser/twitter_test.exs
Original file line number Diff line number Diff line change
@@ -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 =
"<html><head><meta name=\"twitter:image\" " <>
Expand Down
2 changes: 1 addition & 1 deletion test/furlex_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule FurlexTest do
use ExUnit.Case
use ExUnit.Case, async: true

setup do
bypass = Bypass.open()
Expand Down

0 comments on commit 4f786c6

Please sign in to comment.