Skip to content
Open
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
6 changes: 5 additions & 1 deletion lib/waffle/transformations/convert.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ defmodule Waffle.Transformations.Convert do

case result do
{_, 0} ->
{:ok, %Waffle.File{file | path: new_path, is_tempfile?: true}}
if File.exists?(new_path) do
{:ok, %Waffle.File{file | path: new_path, is_tempfile?: true}}
else
{:error, "Transform output file does not exist: #{new_path}"}
end

{error_message, _exit_code} ->
{:error, error_message}
Expand Down
17 changes: 17 additions & 0 deletions test/processor_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ defmodule WaffleTest.Processor do
def transform(:original, _), do: {:blah, ""}
end

defmodule MissingOutputDefinition do
use Waffle.Definition

def transform(:original, _), do: {"true", fn _input, _output -> [] end}
end

test "returns the original path for :noaction transformations" do
{:ok, file} =
Waffle.Processor.process(
Expand Down Expand Up @@ -208,6 +214,17 @@ defmodule WaffleTest.Processor do
)
end

test "returns an error when a successful transformation produces no output" do
assert {:error, message} =
Waffle.Processor.process(
MissingOutputDefinition,
:original,
{Waffle.File.new(@img, MissingOutputDefinition), nil}
)

assert message =~ "Transform output file does not exist:"
end

test "raises an error if the given transformation executable cannot be found" do
assert_raise Waffle.MissingExecutableError, ~r"blah", fn ->
Waffle.Processor.process(
Expand Down