Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thibaultCha/lua-resty-busted
Test OpenResty scripts with busted
https://github.com/thibaultCha/lua-resty-busted
lua-resty ngx-lua openresty
Last synced: 7 days ago
JSON representation
Test OpenResty scripts with busted
- Host: GitHub
- URL: https://github.com/thibaultCha/lua-resty-busted
- Owner: thibaultcha
- Created: 2016-01-15T09:46:59.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-22T02:57:34.000Z (11 months ago)
- Last Synced: 2024-04-14T20:01:52.654Z (7 months ago)
- Topics: lua-resty, ngx-lua, openresty
- Language: Lua
- Size: 3.91 KB
- Stars: 32
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-resty - lua-resty-busted
README
# lua-resty-busted ![Module Version][badge-version-image]
A little hack to test OpenResty scripts with [busted].
By overriding the `busted` executable with the one shipped with this module, busted runs with the [resty-cli] interpreter, which can execute Lua scripts written for OpenResty from the CLI.
### Install
By default, the script is installed under `/usr/local/bin`. You can use the Makefile variables (also from Luarocks) to install it somewhere else.
Luarocks:
```
$ luarocks install lua-resty-busted
```Makefile:
```
$ make install
```Manually: just copy the `bin/busted` script somewhere in your `$PATH`.
### Usage
```lua
describe("openresty script", function()
it("should run in ngx_lua context", function()
assert.equal(0, ngx.OK)
assert.equal(200, ngx.HTTP_OK)
end)
it("should wait", function()
ngx.sleep(3)
assert.is_true(1 == 1)
end)
end)
```From [resty-cli]'s documentation:
> The Lua code is initiated by the init_worker_by_lua directive and run in the context of ngx.timer callback. So all of ngx_lua's Lua APIs available in the ngx.timer callback context are also available in the resty utility. We may remove some of the remaining limitations in the future though.
### License
Work licensed under the MIT License. Please check [Olivine-Labs/busted][busted] for the license of the underlying, actual testing framework, and [OpenResty/lua-resty-cli](https://github.com/openresty/resty-cli) for the license of the interpreter.
[busted]: https://github.com/Olivine-Labs/busted
[resty-cli]: https://github.com/openresty/resty-cli
[badge-version-image]: https://img.shields.io/badge/version-0.0.1-blue.svg?style=flat