uuid.t 576 B

1234567891011121314151617181920212223242526272829
  1. use Test::Nginx::Socket;
  2. our $HttpConfig = <<'_EOC_';
  3. lua_package_path "lib/?.lua;/usr/local/share/lua/5.1/?.lua;;";
  4. _EOC_
  5. repeat_each(3);
  6. plan tests => repeat_each() * (blocks() * 3);
  7. run_tests();
  8. __DATA__
  9. === TEST 1: generate_v4
  10. --- http_config eval: $::HttpConfig
  11. --- config
  12. location /t {
  13. content_by_lua_block {
  14. local uuid = require "resty.t1k.uuid"
  15. ngx.say(uuid.generate_v4())
  16. }
  17. }
  18. --- request
  19. GET /t
  20. --- response_body_like
  21. ^[0-9a-f]{8}[0-9a-f]{4}4[0-9a-f]{3}[89ab][0-9a-f]{3}[0-9a-f]{12}$
  22. --- no_error_log
  23. [error]