lsyncd/tests/utils_test.lua
2022-03-17 02:26:00 +01:00

27 lines
835 B
Lua

dofile( 'tests/testlib.lua' )
cwriteln( '****************************************************************' )
cwriteln( ' Testing Utils Functions ' )
cwriteln( '****************************************************************' )
assert(isTableEqual(
splitQuotedString("-p 22 -i '/home/test/bla blu/id_rsa'"),
{"-p", "22", "-i", "/home/test/bla blu/id_rsa"}
))
-- test string replacement
local testData = {
localPort = 1234,
localHost = "localhorst"
}
assert(replaceCommand("echo ssh ${localHost}:${localPort}", testData) ==
"echo ssh localhorst:1234")
assert(isTableEqual(
replaceCommand({"-p${doesNotExist}", "2${localHost}2", "-i '${localPort}'"}, testData),
{"-p", "2localhorst2", "-i '1234'"}
))
assert(type(lsyncd.get_free_port()) == "number")
os.exit(0)