-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache_tests.erl
More file actions
25 lines (21 loc) · 769 Bytes
/
cache_tests.erl
File metadata and controls
25 lines (21 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-module(cache_tests).
-include_lib("eunit/include/eunit.hrl").
cache_test_() ->
{setup,
fun start/0,
fun stop/1,
fun test_cache/1}.
start() ->
{ok, Pid} = cache:start_link(),
Pid.
stop(_) ->
ok = cache:stop().
test_cache(_) ->
[?_assertMatch({ok, stored, {foo, 123, _Expires}}, cache:store(foo, 123)),
?_assertMatch({error, key_already_exist, {foo, 123, _Expires}},
cache:store(foo, 456)),
?_assertEqual({ok, updated, {foo, 456}}, cache:update(foo, 456)),
?_assertEqual({error, {key_not_found, bar}}, cache:lookup(bar)),
?_assertMatch({ok, 456, _Expires}, cache:lookup(foo)),
?_assertNotMatch([{foo,456,_Expires}], cache:list()),
?_assertMatch({ok, [{foo,456,_Expires}]}, cache:list())].