• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

Mock ubus while testing (1 Viewer)

devkapilbansal

Newcomer
Joined
May 10, 2021
Messages
1
Reaction score
0
Location
Delhi,India
Greetings everyone
I want to test some files using ubus in my local machine(ubuntu) The script uses:-
Lua:
ubus_lib = require('ubus')
ubus = ubus_lib.connect()
data = ubus:call(something)
This script is loaded in another module, ubus was giving nil, that's why I try to mock it using package.loaded. But now the line data = ubus:call(something) is giving error as:
Bash:
lua: ../interface_functions.lua:12: attempt to index global 'ubus' (a nil value)
stack traceback:
    ../interface_functions.lua:12: in main chunk
    [C]: in function 'require'
    test_interface.lua:7: in main chunk
    [C]: ?

Actually, I wanna use a predefined output file for data while testing. How the value of ubus.connect():call(something) can be mocked
 
Top