openresty / openresty/test-nginx
Needs a Lua version
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 455
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
Proposed syntax:
local ngxtest = require 'test_nginx'
local server = ngxtest.start_server(1989) --port
server:config(([[
location /foo {
set $memc_cmd set;
set $memc_key foo;
set $memc_value bar;
memc_pass 127.0.0.1:%s;
}
]]):format(ngxtest.get_memcached_port())
local response = server.request('GET', '/foo')
server:reset() -- for teardown tests
This could be used in any test library with setup/teardown, for example in busted:
local ngxtest = require 'test_nginx'
local server = ngxtest.start_server(1989)
describe('sayfoo', function()
after_each(function()
server:reset()
end)
it('works', function()
server:config([[
location /foo {
init_by_lua '
ngx.status = 200
ngx.print('foo')
ngx.eof()
'
}
]])
assert.same(server:get('/foo'), {status = 200, body = 'foo', headers = {...}})
end)
end)
This is just an example, I hope you get my point :)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing test_nginx interface referenced in the examples and compare its server lifecycle with the proposed Lua API. Check how configuration, requests, ports, and reset-based teardown are represented, then determine whether the busted setup/teardown example can be supported. Done means the requested Lua-facing test workflow is defined and its scope is agreed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- testing-qa, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100