openresty / openresty/test-nginx

Needs a Lua version

Open
#5 1 comment 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.