openresty / test-nginx

Data-driven test scaffold for Nginx C module and OpenResty Lua library development
http://search.cpan.org/dist/Test-Nginx
440 stars 105 forks source link

How do I provide my nginx.conf #90

Open ktalebian opened 5 years ago

ktalebian commented 5 years ago

I'm trying to use the tutorial and get my testing with Test::Nginx started. Here is what I saw

use Test::Nginx::Socket 'no_plan';

run_tests();

__DATA__

=== TEST 1: hello, world
This is just a simple demonstration of the
echo directive provided by ngx_http_echo_module.
--- config
location = /t {
    echo "hello, world!";
}
--- request
GET /t
--- response_body
hello, world!
--- error_code: 200

I don't understand how I can use my own server/nginx.cnf to run the tests? This is already starting a server and doing the test. I already have an nginx.cnf that I like to include. How do I do that?

woodgear commented 3 years ago

take a look here https://github.com/openresty/test-nginx/blob/da2c049d2bd6a1fcd04685d7f7a1534e4575866d/lib/Test/Nginx/Util.pm#L884 to fully control the nginx.conf, you may want to use sth like this https://github.com/apache/apisix/blob/912bbbb3e1b0199c42b475f47952a2deac3a3366/t/APISIX.pm#L218