Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increase Task timeout and add test async #2

Merged
merged 1 commit into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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