|
1 | 1 | defmodule Imageflow.Integration.GraphTest do |
2 | 2 | use ExUnit.Case |
3 | 3 |
|
4 | | - alias Imageflow.{Graph, Native} |
| 4 | + alias Imageflow.{Graph, Native, Result} |
5 | 5 |
|
6 | 6 | @input_path "test/fixtures/elixir-logo.jpg" |
7 | 7 | @output_path "/tmp/output.png" |
8 | 8 |
|
9 | 9 | test "can pipe multiple operations" do |
10 | | - assert :ok = |
11 | | - Graph.new() |
12 | | - |> Graph.decode_file(@input_path) |
13 | | - |> Graph.constrain(20, 20) |
14 | | - |> Graph.rotate_270() |
15 | | - |> Graph.transpose() |
16 | | - |> Graph.color_filter("invert") |
17 | | - |> Graph.encode_to_file(@output_path) |
18 | | - |> Graph.run() |
| 10 | + run_result = |
| 11 | + Graph.new() |
| 12 | + |> Graph.decode_file(@input_path) |
| 13 | + |> Graph.constrain(20, 20) |
| 14 | + |> Graph.rotate_270() |
| 15 | + |> Graph.transpose() |
| 16 | + |> Graph.color_filter("invert") |
| 17 | + |> Graph.encode_to_file(@output_path) |
| 18 | + |> Graph.run() |
| 19 | + |
| 20 | + assert match?({:ok, _job, _graph}, run_result) |
19 | 21 | end |
20 | 22 |
|
21 | 23 | test "can generate multiple images" do |
@@ -47,12 +49,28 @@ defmodule Imageflow.Integration.GraphTest do |
47 | 49 | end |
48 | 50 |
|
49 | 51 | test "can handle multiple operations" do |
50 | | - assert :ok = |
51 | | - Graph.new() |
52 | | - |> Graph.decode_file(@input_path) |
53 | | - |> Graph.flip_vertical() |
54 | | - |> Graph.transpose() |
55 | | - |> Graph.encode_to_file("/tmp/rotated.png") |
56 | | - |> Graph.run() |
| 52 | + run_result = |
| 53 | + Graph.new() |
| 54 | + |> Graph.decode_file(@input_path) |
| 55 | + |> Graph.flip_vertical() |
| 56 | + |> Graph.transpose() |
| 57 | + |> Graph.encode_to_file("/tmp/rotated.png") |
| 58 | + |> Graph.run() |
| 59 | + |
| 60 | + assert match?({:ok, _job, _graph}, run_result) |
| 61 | + end |
| 62 | + |
| 63 | + test "can encode to file" do |
| 64 | + {:ok, job, graph} = |
| 65 | + Graph.new() |
| 66 | + |> Graph.decode_file(@input_path) |
| 67 | + |> Graph.flip_vertical() |
| 68 | + |> Graph.transpose() |
| 69 | + |> Graph.encode_to_string() |
| 70 | + |> Graph.run() |
| 71 | + |
| 72 | + {:ok, %Result{} = results} = Graph.get_results(job, graph) |
| 73 | + |
| 74 | + assert is_bitstring(results.output) |
57 | 75 | end |
58 | 76 | end |
0 commit comments