-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Cache.put / Cache.fetch tests p.282 #1
- Loading branch information
Showing
2 changed files
with
16 additions
and
4 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 |
---|---|---|
@@ -1,11 +1,23 @@ | ||
defmodule InfoSysTest.CacheTest do | ||
use ExUnit.Case, async: true | ||
alias InfoSys.Cache | ||
@@moduletag :clear_interval: 100 | ||
@moduletag clear_interval: 100 | ||
|
||
setup %{test: name, clear_interval: clear_interval} do | ||
{:ok, pid} = Cache.start_link(name: name, clear_interval: clear_interval) | ||
{ok, name: name, pid: pid} | ||
{:ok, name: name, pid: pid} | ||
end | ||
|
||
test "key value pairs can be put and fetched from cache", %{name: name} do | ||
assert :ok = Cache.put(name, :key1, :value1) | ||
assert :ok = Cache.put(name, :key2, :value2) | ||
|
||
assert Cache.fetch(name, :key1) == {:ok, :value1} | ||
assert Cache.fetch(name, :key2) == {:ok, :value2} | ||
end | ||
|
||
test "unfound entry returns error", %{name: name} do | ||
assert Cache.fetch(name, :notexists) == :error | ||
end | ||
|
||
end |