Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emoragaf committed Jun 28, 2022
1 parent 51a7b50 commit fa7ffcc
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/actions/store_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,37 @@ defmodule WaffleTest.Actions.Store do
Application.put_env(:waffle, :version_timeout, 15_000)
end

test "recv_timeout" do
Application.put_env(:waffle, :recv_timeout, 1)

with_mock Waffle.Storage.S3,
put: fn DummyDefinition, _, {%{file_name: "favicon.ico", path: _}, nil} ->
{:ok, "favicon.ico"}
end do
assert DummyDefinition.store("https://www.google.com/favicon.ico") ==
{:error, :recv_timeout}
end

Application.put_env(:waffle, :recv_timeout, 5_000)
end

test "recv_timeout with a filename" do
Application.put_env(:waffle, :recv_timeout, 1)

with_mock Waffle.Storage.S3,
put: fn DummyDefinition, _, {%{file_name: "newfavicon.ico", path: _}, nil} ->
{:ok, "newfavicon.ico"}
end do
assert DummyDefinition.store(%{
remote_path: "https://www.google.com/favicon.ico",
filename: "newfavicon.ico"
}) ==
{:error, :recv_timeout}
end

Application.put_env(:waffle, :recv_timeout, 5_000)
end

test "accepts remote files" do
with_mock Waffle.Storage.S3,
put: fn DummyDefinition, _, {%{file_name: "favicon.ico", path: _}, nil} ->
Expand Down

0 comments on commit fa7ffcc

Please sign in to comment.