Skip to content

Commit 4a436a6

Browse files
committed
test: add async example test
1 parent a2acba9 commit 4a436a6

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

.github/workflows/nginx.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ jobs:
7575
working-directory: nginx
7676
env:
7777
TEST_NGINX_GLOBALS: >-
78+
load_module ${{ github.workspace }}/nginx/objs/ngx_http_async_module.so;
7879
load_module ${{ github.workspace }}/nginx/objs/ngx_http_awssigv4_module.so;
7980
load_module ${{ github.workspace }}/nginx/objs/ngx_http_curl_module.so;
8081
load_module ${{ github.workspace }}/nginx/objs/ngx_http_upstream_custom_module.so;

examples/config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if [ $HTTP = YES ]; then
1515
ngx_rust_target_type=EXAMPLE
1616
ngx_rust_target_features=
1717

18-
if [ "$ngx_module_link" = DYNAMIC ]; then
18+
if :; then
1919
ngx_module_name=ngx_http_async_module
2020
ngx_module_libs="-lm"
2121
ngx_rust_target_name=async

examples/t/async.t

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/perl
2+
3+
# (C) Nginx, Inc
4+
5+
# Tests for ngx-rust example modules.
6+
7+
###############################################################################
8+
9+
use warnings;
10+
use strict;
11+
12+
use Test::More;
13+
14+
BEGIN { use FindBin; chdir($FindBin::Bin); }
15+
16+
use lib 'lib';
17+
use Test::Nginx;
18+
19+
###############################################################################
20+
21+
select STDERR; $| = 1;
22+
select STDOUT; $| = 1;
23+
24+
my $t = Test::Nginx->new()->has(qw/http/)->plan(1)
25+
->write_file_expand('nginx.conf', <<'EOF');
26+
27+
%%TEST_GLOBALS%%
28+
29+
daemon off;
30+
31+
events {
32+
}
33+
34+
http {
35+
%%TEST_GLOBALS_HTTP%%
36+
37+
server {
38+
listen 127.0.0.1:8080;
39+
server_name localhost;
40+
41+
location / {
42+
async on;
43+
}
44+
}
45+
}
46+
47+
EOF
48+
49+
$t->write_file('index.html', '');
50+
$t->run();
51+
52+
###############################################################################
53+
54+
like(http_get('/', sleep => 2.1), qr/X-Async-Time:/, 'async handler');
55+
56+
###############################################################################

0 commit comments

Comments
 (0)