Now we store the tables when they are created
This commit is contained in:
parent
391af1a96a
commit
818205e19b
3 changed files with 37 additions and 22 deletions
|
@ -1,33 +1,42 @@
|
|||
-module(ggs_coordinator_test).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
start_link_test() ->
|
||||
{ok, Coord} = ggs_coordinator:start_link(), % Start
|
||||
PInfo = erlang:process_info(Coord), % Check process info
|
||||
ggs_coordinator:stop(""), % Clean up
|
||||
timer:sleep(100), % Wait for cleaning..
|
||||
?assert((PInfo /= undefined)). % Did the server start?
|
||||
coordinator_test_() ->
|
||||
{foreach,
|
||||
fun() ->
|
||||
{ok, _Coord} = ggs_coordinator:start_link(),
|
||||
timer:sleep(100)
|
||||
end,
|
||||
fun(_X) ->
|
||||
ggs_coordinator:stop("End of test"),
|
||||
timer:sleep(100)
|
||||
end,
|
||||
[
|
||||
fun test_start_link/0,
|
||||
fun test_stop/0,
|
||||
fun test_join_bad_table/0,
|
||||
fun test_create_table/0
|
||||
]
|
||||
}.
|
||||
|
||||
stop_test() ->
|
||||
test_start_link() ->
|
||||
% Check process info
|
||||
PInfo = whereis(ggs_coordinator),
|
||||
?assert((PInfo /= undefined)). % Did the server start?
|
||||
|
||||
test_stop() ->
|
||||
ok = ggs_coordinator:stop(""), % Extra cleaning
|
||||
{ok, Coord} = ggs_coordinator:start_link(), % Start server
|
||||
ggs_coordinator:stop("Terminate now"), % Send stop message
|
||||
timer:sleep(100), % Wait for cleaning..
|
||||
?assert((erlang:process_info(Coord) == undefined)). % Did it stop?
|
||||
timer:sleep(100),
|
||||
% Did it stop?
|
||||
?assert((whereis(ggs_coordinator)) == undefined).
|
||||
|
||||
join_bad_table_test() ->
|
||||
{ok, _Coord} = ggs_coordinator:start_link(),
|
||||
test_join_bad_table() ->
|
||||
Response = ggs_coordinator:join_table("Nonexistant table"),
|
||||
ggs_coordinator:stop(""),
|
||||
timer:sleep(100),
|
||||
?assert(Response == {error, no_such_table}).
|
||||
|
||||
|
||||
create_table_test() ->
|
||||
{ok, _Coord} = ggs_coordinator:start_link(),
|
||||
test_create_table() ->
|
||||
% Forcibly create a table. This functionality should be disabled
|
||||
% in the production system, but is pretty nice for testing.
|
||||
Response = ggs_coordinator:create_table({force, 1337}),
|
||||
ggs_coordinator:stop(""),
|
||||
timer:sleep(100),
|
||||
?assert(Response == {ok, 1337}).
|
||||
|
|
Reference in a new issue