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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
-module(mem3_test).
-include("../include/common.hrl").
-include("../include/config.hrl").
-include_lib("eunit/include/eunit.hrl").
%% TEST SETUP
all_tests_test_() ->
{"membership3 tests",
[
{setup,
fun test_setup/0,
fun test_teardown/1,
fun(Pid) ->
{with, Pid,
[
fun init/1,
fun join_first/1
]}
end}
]
}.
test_setup() ->
Config = #config{n=3,r=2,w=2,q=3,directory="/srv/db",
storage_mod="dynomite_couch_storage"},
{ok, Pid} = mem3:start_link([{test,true}, {config, Config}]),
Pid.
test_teardown(Pid) ->
exit(Pid, shutdown).
%% TESTS
init(_Pid) ->
#mem{args=Args} = mem3:state(),
Test = proplists:get_value(test, Args),
?assertEqual(true, Test).
join_first(_Pid) ->
mem3:join(first, [{1, a, []}, {2, b, []}]),
Fullmap = mem3:fullmap(),
?assertEqual(16, length(Fullmap)),
Pmap = mem3:partitions(),
?assertEqual(8, length(Pmap)),
ok.
|