I haven't been able to find documentation anywhere on testing modules that contain OpenResty components.
For example:
redis = require "resty.redis"
-- rest of lua module I want to test
busted utils.moon
✱
0 successes / 0 failures / 1 error / 0 pending : 0.002996 seconds
Error → utils.moon @ 1
suite utils.moon
utils.moon:1: module 'resty.redis' not found:
no field package.preload['resty.redis']
no file './src/resty/redis.lua'
no file './src/resty/redis/resty/redis.lua'
no file './src/resty/redis/init.lua'
no file '/usr/local/share/lua/5.1/resty/redis.lua'
no file '/usr/local/share/lua/5.1/resty/redis/init.lua'
no file '/root/.luarocks/share/lua/5.1/resty/redis.lua'
no file '/root/.luarocks/share/lua/5.1/resty/redis/init.lua'
no file '/usr/local/share/lua/5.1/resty/redis.lua'
no file '/usr/local/share/lua/5.1/resty/redis/init.lua'
no file '/root/.luarocks/share/lua/5.1/resty/redis.lua'
no file '/root/.luarocks/share/lua/5.1/resty/redis/init.lua'
no file '/usr/share/lua/5.1//resty/redis.lua'
no file '/usr/share/lua/5.1//resty/redis/init.lua'
no file './resty/redis.lua'
no file '/usr/local/share/lua/5.1/resty/redis.lua'
no file '/usr/local/share/lua/5.1/resty/redis/init.lua'
no file '/usr/local/lib/lua/5.1/resty/redis.lua'
no file '/usr/local/lib/lua/5.1/resty/redis/init.lua'
no file '/usr/share/lua/5.1/resty/redis.lua'
no file '/usr/share/lua/5.1/resty/redis/init.lua'
no file './csrc/resty/redis.so'
no file './csrc/resty/redis/resty/redis.so'
no file '/usr/local/lib/lua/5.1/resty/redis.so'
no file '/root/.luarocks/lib/lua/5.1/resty/redis.so'
no file '/usr/local/lib/lua/5.1/resty/redis.so'
no file '/root/.luarocks/lib/lua/5.1/resty/redis.so'
no file './resty/redis.so'
no file '/usr/local/lib/lua/5.1/resty/redis.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.1/resty/redis.so'
no file '/usr/lib/lua/5.1/resty/redis.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './csrc/resty.so'
no file './csrc/resty/resty.so'
no file '/usr/local/lib/lua/5.1/resty.so'
no file '/root/.luarocks/lib/lua/5.1/resty.so'
no file '/usr/local/lib/lua/5.1/resty.so'
no file '/root/.luarocks/lib/lua/5.1/resty.so'
no file './resty.so'
no file '/usr/local/lib/lua/5.1/resty.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.1/resty.so'
no file '/usr/lib/lua/5.1/resty.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
Seems like it must be a pretty common need to test lapis code that has OpenResty dependencies.
Module "resty.redis" would not work outside of openresty process, because it uses nginx Lua functions, which do not exist in normal Lua process (e.g., in busted).
Lapis has a module to test applications which do requests.
This topic is covered in Lapis docs.
I haven't been able to find documentation anywhere on testing modules that contain OpenResty components.
For example:
Seems like it must be a pretty common need to test lapis code that has OpenResty dependencies.