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

Fix internal error on info operation in pipeline #4

Merged
merged 1 commit into from
Nov 1, 2023
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: 4 additions & 0 deletions lib/plug_image_processing/operations/info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ defmodule PlugImageProcessing.Operations.Info do

alias Vix.Vips.Image

def new(_image, _params, _config) do
{:error, :invalid_operation}
end

defimpl PlugImageProcessing.Info do
def process(operation) do
{:ok,
Expand Down
26 changes: 26 additions & 0 deletions test/plug_image_processing/web_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,31 @@ defmodule PlugImageProcessing.WebTest do
assert image_metadata["has_alpha"] === false
assert image_metadata["channels"] === 3
end

test "pipeline", %{config: config} do
plug_opts = Web.init(config)
conn = conn(:get, "/imageproxy/pipeline", %{operations: Jason.encode!([%{operation: "crop", params: %{width: 20, height: 50}}]), url: "http://example.org/valid.jpg"})
conn = Web.call(conn, plug_opts)

{:ok, image} = conn_to_image(conn)

assert Image.width(image) === 20
assert Image.height(image) === 50
end

test "pipeline info", %{config: config} do
plug_opts = Web.init(config)

conn =
conn(:get, "/imageproxy/pipeline", %{
operations: Jason.encode!([%{operation: "crop", params: %{width: 20, height: 50}}, %{operation: "info"}]),
url: "http://example.org/valid.jpg"
})

conn = Web.call(conn, plug_opts)

assert conn.status === 400
assert conn.resp_body === "Bad request: :invalid_operation"
end
end
end
Loading