emqx_sequence_SUITE.erl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. %% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
  2. %%
  3. %% Licensed under the Apache License, Version 2.0 (the "License");
  4. %% you may not use this file except in compliance with the License.
  5. %% You may obtain a copy of the License at
  6. %%
  7. %% http://www.apache.org/licenses/LICENSE-2.0
  8. %%
  9. %% Unless required by applicable law or agreed to in writing, software
  10. %% distributed under the License is distributed on an "AS IS" BASIS,
  11. %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. %% See the License for the specific language governing permissions and
  13. %% limitations under the License.
  14. -module(emqx_sequence_SUITE).
  15. -compile(export_all).
  16. -compile(nowarn_export_all).
  17. -include_lib("eunit/include/eunit.hrl").
  18. -import(emqx_sequence, [nextval/2, reclaim/2]).
  19. all() ->
  20. [sequence_generate].
  21. sequence_generate(_) ->
  22. ok = emqx_sequence:create(seqtab),
  23. ?assertEqual(1, nextval(seqtab, key)),
  24. ?assertEqual(2, nextval(seqtab, key)),
  25. ?assertEqual(3, nextval(seqtab, key)),
  26. ?assertEqual(2, reclaim(seqtab, key)),
  27. ?assertEqual(1, reclaim(seqtab, key)),
  28. ?assertEqual(0, reclaim(seqtab, key)),
  29. ?assertEqual(false, ets:member(seqtab, key)),
  30. ?assertEqual(1, nextval(seqtab, key)),
  31. ?assert(emqx_sequence:delete(seqtab)).