1

I have a bunch of lua files which I use to handle different urls in nginx, like this:

location /tag {
    set $env       'prod';
    set $redis_ttl 7776000;
    content_by_lua_file 'conf/match.lua';
    log_by_lua_file     'conf/log.lua';
}

Each file is a simple script, without any module structure. When the number of lines and files were low, I tested everything manually, but now I feel like I need to do unit testing. Busted framework looks like a logical choice, though I can't understand how to fit it right into openresty model.

Thomas W
  • 14,757
  • 6
  • 48
  • 67
Vladimir Lebedev
  • 1,207
  • 1
  • 11
  • 25

2 Answers2

1

I'm not really familiar with Busted, however, if you're comfortable enough using Perl; the author of Openresty has a testing scaffold specifically to test nginx-lua code named: Test::Nginx::Socket::Lua

You can find as a CPAN module here and the source code here.

danielgpm
  • 1,609
  • 12
  • 26
0

Late to the party, but here's how you can use Busted in a transparent way with OpenResty: https://github.com/lunarmodules/busted/issues/414#issuecomment-792614808

Tieske
  • 363
  • 3
  • 10