kvs_SUITE.erl 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. -module(kvs_SUITE).
  2. -include_lib("common_test/include/ct.hrl").
  3. -include_lib("kvs/include/entry.hrl").
  4. -export([
  5. suite/0,
  6. all/0,
  7. groups/0,
  8. init_per_suite/1,
  9. end_per_suite/1,
  10. init_per_group/2,
  11. end_per_group/2,
  12. access/1,
  13. comment/1,
  14. user/1,
  15. entry/1
  16. ]).
  17. suite() -> [{timetrap,{seconds,30}}].
  18. all() -> [{group, feed},{group,acl}].
  19. groups() -> [{feed,[entry,comment,user]},
  20. {acl,[access]}].
  21. init_per_suite(Config) ->
  22. application:start(mnesia),
  23. application:start(kvs),
  24. application:set_env(kvs, schema, [kvs_user, kvs_acl, kvs_feed, kvs_subscription]),
  25. application:set_env(kvs, dba, store_mnesia),
  26. kvs:join(),
  27. kvs:init_db(),
  28. ct:log("-> Dir ~p~n",[kvs:dir()]),
  29. Config.
  30. end_per_suite(Config) ->
  31. kvs:destroy(),
  32. application:stop(kvs),
  33. ok.
  34. init_per_group(_Name, _Config) ->
  35. ok.
  36. end_per_group(_Name, _Config) ->
  37. ok.
  38. access(Config) -> ok.
  39. comment(Config) -> ok.
  40. user(Config) -> ok.
  41. entry(Config) ->
  42. Fid = 1,
  43. kvs:add(#entry{id={1,Fid},feed_id=Fid}),
  44. kvs:add(#entry{id={2,Fid},feed_id=Fid}),
  45. L = kvs:entries(kvs:get(feed,Fid),entry,undefined),
  46. List = [ Key || #entry{id=Key} <- L ],
  47. Length = length(List),
  48. 2 == Length,
  49. List == [{1,1},{2,1}],
  50. ct:log("-> List ~p~n", [List]),
  51. ok.