Skip to content

Commit

Permalink
test case
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Oct 10, 2023
1 parent 4398bbe commit 8f0d255
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ngx_http_lua_kong_request_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


#define KONG_REQUEST_ID_MAX_LEN 16
#define KONG_REQUEST_ID_FORMAT "%08x%08x"
#define KONG_REQUEST_ID_FORMAT "%08xD%08xD"


static ngx_int_t
Expand Down
40 changes: 40 additions & 0 deletions t/010-request-id.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# vim:set ft= ts=4 sw=4 et:

use Test::Nginx::Socket::Lua;
use Cwd qw(cwd);

plan tests => repeat_each() * (blocks() * 5);

my $pwd = cwd();

$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();

no_long_string();
#no_diff();

run_tests();

__DATA__
=== TEST 1: $kong_request_id works
--- config
location /t {
content_by_lua_block {
local rid = ngx.var.kong_request_id
assert(ngx.re.match(rid, "[0-9a-f]{16}"))
ngx.say("ok")
}
}
--- request
GET /t
--- response_body_like
ok
--- error_code: 200
--- no_error_log
[error]
[crit]
[alert]

0 comments on commit 8f0d255

Please sign in to comment.