Coder Social home page Coder Social logo

lua-resty-busted's Introduction

lua-resty-busted Module Version

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

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 for the license of the underlying, actual testing framework, and OpenResty/lua-resty-cli for the license of the interpreter.

lua-resty-busted's People

Contributors

thibaultcha avatar machados avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.