-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from appunite/blackhole-store
Add blackhole storage
- Loading branch information
Showing
5 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
defmodule Imager.Store.Blackhole do | ||
@behaviour Imager.Store | ||
|
||
@moduledoc """ | ||
`/dev/null` of the stores. All writes will discard data and all reads | ||
will automatically fail. | ||
""" | ||
|
||
def retrieve(_path, _ops), do: :error | ||
|
||
def store(_path, _mime, stream, _opts), do: stream | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
defmodule Imager.Store.BlackholeTest do | ||
use ExUnit.Case, async: true | ||
use ExUnitProperties | ||
|
||
alias Imager.Store.Blackhole, as: Subject | ||
|
||
property "retreive always return error" do | ||
check all path <- binary() do | ||
assert :error = Subject.retrieve(path, []) | ||
end | ||
end | ||
|
||
test "returns provided stream as is" do | ||
stream = Stream.interval(10) | ||
|
||
assert ^stream = Subject.store("", "", stream, []) | ||
end | ||
end |