Fixed 'concurrent' inserts test
This commit is contained in:
@@ -145,15 +145,29 @@ select_many_records() ->
|
|||||||
1024,
|
1024,
|
||||||
length(rows(sqlite3:sql_exec(ct, "select * from many_records;")))).
|
length(rows(sqlite3:sql_exec(ct, "select * from many_records;")))).
|
||||||
|
|
||||||
%% concurrent_inserts_test() ->
|
%% note that inserts are actually serialized by gen_server
|
||||||
%% sqlite3:open(concurrent, [in_memory]), %% doing this test not in memory is much slower!
|
concurrent_inserts_test() ->
|
||||||
%% drop_table_if_exists(concurrent, t),
|
N = 1024,
|
||||||
%% sqlite3:create_table(concurrent, t, [{id, integer}]),
|
sqlite3:open(concurrent, [in_memory]), %% doing this test not in memory is much slower!
|
||||||
%% [spawn(fun () -> sqlite3:write(concurrent, t, [{id, X}]) end) || X <- lists:seq(1, 1024)],
|
drop_table_if_exists(concurrent, t),
|
||||||
%% ?assertEqual(
|
sqlite3:create_table(concurrent, t, [{id0, integer}]),
|
||||||
%% 1024,
|
Self = self(),
|
||||||
%% length(rows(sqlite3:read_all(concurrent, t)))),
|
[spawn(fun () ->
|
||||||
%% sqlite3:close(concurrent). %% doesn't pass at the moment!
|
sqlite3:write(concurrent, t, [{id0, X}]),
|
||||||
|
Self ! {finished, N}
|
||||||
|
end) || X <- lists:seq(1, N)],
|
||||||
|
loop_concurrent_inserts(N),
|
||||||
|
?assertEqual(
|
||||||
|
N, length(rows(sqlite3:read_all(concurrent, t)))),
|
||||||
|
sqlite3:close(concurrent).
|
||||||
|
|
||||||
|
loop_concurrent_inserts(0) ->
|
||||||
|
ok;
|
||||||
|
loop_concurrent_inserts(N) ->
|
||||||
|
receive
|
||||||
|
{finished, _} ->
|
||||||
|
loop_concurrent_inserts(N - 1)
|
||||||
|
end.
|
||||||
|
|
||||||
nonexistent_table_info() ->
|
nonexistent_table_info() ->
|
||||||
?assertEqual(table_does_not_exist, sqlite3:table_info(ct, nonexistent)).
|
?assertEqual(table_does_not_exist, sqlite3:table_info(ct, nonexistent)).
|
||||||
|
|||||||
Reference in New Issue
Block a user