Skip to content

Commit dc123d1

Browse files
committed
add missing tests
1 parent 69ca223 commit dc123d1

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

lib/scenic/cache/term.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule Scenic.Cache.Term do
1111
alias Scenic.Cache
1212
alias Scenic.Cache.Hash
1313

14-
# import IEx
14+
# import IEx
1515

1616
# --------------------------------------------------------
1717
def load(path, hash, opts \\ [])

test/scenic/cache/file_test.exs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ defmodule Scenic.Cache.FileReadTest do
8888
decompress: true
8989
) == {:error, :hash_failure}
9090
end
91+
92+
test "read passes through errors" do
93+
# missing term file
94+
assert Cache.File.read(
95+
"not/valid/path",
96+
@invalid_sha256,
97+
hash: :sha256
98+
) == {:error, :enoent}
99+
end
91100
end
92101

93102
defmodule Scenic.Cache.FileLoadTest do
@@ -187,4 +196,13 @@ defmodule Scenic.Cache.FileLoadTest do
187196
decompress: true
188197
) == {:error, :hash_failure}
189198
end
199+
200+
test "load passes through errors" do
201+
# missing term file
202+
assert Cache.File.load(
203+
"not/valid/path",
204+
@invalid_sha256,
205+
hash: :sha256
206+
) == {:error, :enoent}
207+
end
190208
end

test/scenic/cache/term_test.exs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ defmodule Scenic.Cache.TermReadTest do
7575
@sample_sha
7676
) == {:error, :invalid_term}
7777
end
78+
79+
test "read passes through errors" do
80+
# missing term file
81+
assert Cache.Term.read(
82+
"not/valid/path",
83+
@invalid_sha256,
84+
hash: :sha256
85+
) == {:error, :enoent}
86+
end
7887
end
7988

8089
defmodule Scenic.Cache.TermLoadTest do
@@ -98,6 +107,9 @@ defmodule Scenic.Cache.TermLoadTest do
98107
@sample_path "test/artifacts/sample_file"
99108
@sample_sha "2PGNXGkoTc4stYncIe-qCdZFuw0"
100109

110+
@non_term_path "test/artifacts/sample_file"
111+
@non_term_sha "2PGNXGkoTc4stYncIe-qCdZFuw0"
112+
101113
@cache_table :scenic_cache_key_table
102114
@scope_table :scenic_cache_scope_table
103115

@@ -155,4 +167,19 @@ defmodule Scenic.Cache.TermLoadTest do
155167
@sample_sha
156168
) == {:error, :invalid_term}
157169
end
170+
171+
test "load passes through errors" do
172+
# missing term file
173+
assert Cache.Term.load(
174+
"not/valid/path",
175+
@invalid_sha256,
176+
hash: :sha256
177+
) == {:error, :enoent}
178+
179+
# badly formatted term file
180+
assert Cache.Term.load(
181+
@non_term_path,
182+
@non_term_sha
183+
) == {:error, :invalid_term}
184+
end
158185
end

test/scenic/graph_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defmodule Scenic.GraphTest do
1414
alias Scenic.Primitive.Rectangle
1515
alias Scenic.Primitive.Line
1616

17-
import IEx
17+
# import IEx
1818

1919
@root_uid 0
2020

0 commit comments

Comments
 (0)