TT#165251 use consistently :new()

We were using a mix of .new() and :new() and
that lead us to errors when calling new with parameters

Just be consistent and choose one

Change-Id: Icc2078efb377b80942b2fb518db52df339ecda6a
mr11.0.1
Victor Seva 3 years ago
parent b30d7c1a43
commit a06903a0e3

@ -33,7 +33,7 @@ local hdrMock = {
crit = logging.FATAL crit = logging.FATAL
} }
} }
function hdrMock.new() function hdrMock:new()
local t = {} local t = {}
t.__class__ = 'hdrMock' t.__class__ = 'hdrMock'

@ -39,14 +39,14 @@ local ksrMock = {
} }
} }
local ksrMock_MT = { __index = ksrMock, __newindex = lemock.controller():mock() } local ksrMock_MT = { __index = ksrMock, __newindex = lemock.controller():mock() }
function ksrMock.new() function ksrMock:new()
local t = {} local t = {}
if os.getenv('RESULTS') then if os.getenv('RESULTS') then
local file = os.getenv('RESULTS').."/"..logfile local file = os.getenv('RESULTS').."/"..logfile
t._logger = log_file(file, "%Y-%m-%d") t._logger = log_file(file, "%Y-%m-%d")
end end
t.hdr = hdrMock.new() t.hdr = hdrMock:new()
t.pv = pvMock.new(t.hdr) t.pv = pvMock:new(t.hdr)
function t.log(level, message) function t.log(level, message)
if not t._logger_levels[level] then if not t._logger_levels[level] then
error(string.format("level %s unknown", tostring(level))) error(string.format("level %s unknown", tostring(level)))
@ -71,7 +71,7 @@ local ksrMock_MT = { __index = ksrMock, __newindex = lemock.controller():mock()
function t.crit(message) function t.crit(message)
t._logger:log(logging.FATAL, message) t._logger:log(logging.FATAL, message)
end end
t.pvx = pvxMock.new(t.pv) t.pvx = pvxMock:new(t.pv)
setmetatable(t, ksrMock_MT) setmetatable(t, ksrMock_MT)
return t return t
end end

@ -35,7 +35,7 @@ local pvMock = {
crit = logging.FATAL crit = logging.FATAL
} }
} }
function pvMock.new(hdr) function pvMock:new(hdr)
local t = {} local t = {}
t.__class__ = 'pvMock' t.__class__ = 'pvMock'

@ -32,7 +32,7 @@ local pvxMock = {
crit = logging.FATAL crit = logging.FATAL
} }
} }
function pvxMock.new(pv) function pvxMock:new(pv)
local t = {} local t = {}
t.__class__ = 'pvxMock' t.__class__ = 'pvxMock'

@ -41,7 +41,7 @@ NGCPAPIClient_MT.__tostring = function (t)
return string.format("config:%s", utable.tostring(t.config)) return string.format("config:%s", utable.tostring(t.config))
end end
function NGCPAPIClient.new(config) function NGCPAPIClient:new(config)
local t = NGCPAPIClient.init(utils.merge_defaults(config, defaults)) local t = NGCPAPIClient.init(utils.merge_defaults(config, defaults))
setmetatable( t, NGCPAPIClient_MT ) setmetatable( t, NGCPAPIClient_MT )
return t return t

@ -50,7 +50,7 @@ NGCPDlgCounters_MT.__tostring = function (t)
utable.tostring(t.pair)); utable.tostring(t.pair));
end end
-- luacheck: globals KSR -- luacheck: globals KSR
function NGCPDlgCounters.new(config) function NGCPDlgCounters:new(config)
local t = NGCPDlgCounters.init(utils.merge_defaults(config, defaults)) local t = NGCPDlgCounters.init(utils.merge_defaults(config, defaults))
setmetatable( t, NGCPDlgCounters_MT ) setmetatable( t, NGCPDlgCounters_MT )
return t return t
@ -59,8 +59,8 @@ end
function NGCPDlgCounters.init(config) function NGCPDlgCounters.init(config)
return { return {
config = config, config = config,
central = NGCPRedis.new(config.central), central = NGCPRedis:new(config.central),
pair = NGCPRedis.new(config.pair) pair = NGCPRedis:new(config.pair)
} }
end end

@ -49,7 +49,7 @@ NGCPDlgList_MT.__tostring = function (t)
utable.tostring(t.pair)); utable.tostring(t.pair));
end end
-- luacheck: globals KSR -- luacheck: globals KSR
function NGCPDlgList.new(config) function NGCPDlgList:new(config)
local t = NGCPDlgList.init(utils.merge_defaults(config, defaults)) local t = NGCPDlgList.init(utils.merge_defaults(config, defaults))
setmetatable( t, NGCPDlgList_MT ) setmetatable( t, NGCPDlgList_MT )
return t return t
@ -58,8 +58,8 @@ end
function NGCPDlgList.init(config) function NGCPDlgList.init(config)
return { return {
config = config, config = config,
central = NGCPRedis.new(config.central), central = NGCPRedis:new(config.central),
pair = NGCPRedis.new(config.pair) pair = NGCPRedis:new(config.pair)
} }
end end

@ -42,7 +42,7 @@ NGCPLoop_MT.__tostring = function (t)
utable.tostring(t.config)); utable.tostring(t.config));
end end
-- luacheck: globals KSR -- luacheck: globals KSR
function NGCPLoop.new(config) function NGCPLoop:new(config)
local t = NGCPLoop.init(utils.merge_defaults(config, defaults)) local t = NGCPLoop.init(utils.merge_defaults(config, defaults))
setmetatable( t, NGCPLoop_MT ) setmetatable( t, NGCPLoop_MT )
return t return t
@ -51,7 +51,7 @@ end
function NGCPLoop.init(config) function NGCPLoop.init(config)
return { return {
config = config, config = config,
redis = NGCPRedis.new(config) redis = NGCPRedis:new(config)
} }
end end

@ -43,7 +43,7 @@ NGCPPush_MT.__tostring = function (t)
return string.format("config:%s", utable.tostring(t.config)) return string.format("config:%s", utable.tostring(t.config))
end end
function NGCPPush.new(config) function NGCPPush:new(config)
local t = NGCPPush.init(utils.merge_defaults(config, defaults)); local t = NGCPPush.init(utils.merge_defaults(config, defaults));
setmetatable( t, NGCPPush_MT ) setmetatable( t, NGCPPush_MT )
return t; return t;
@ -53,7 +53,7 @@ function NGCPPush.init(config)
return { return {
config = config, config = config,
c = curl.easy_init(), c = curl.easy_init(),
redis = NGCPRedis.new(config.central) redis = NGCPRedis:new(config.central)
} }
end end

@ -43,7 +43,7 @@ NGCPRecentCalls_MT.__tostring = function (t)
utable.tostring(t.config), utable.tostring(t.redis)) utable.tostring(t.config), utable.tostring(t.redis))
end end
-- luacheck: globals KSR -- luacheck: globals KSR
function NGCPRecentCalls.new(config) function NGCPRecentCalls:new(config)
local t = NGCPRecentCalls.init(utils.merge_defaults(config, defaults)) local t = NGCPRecentCalls.init(utils.merge_defaults(config, defaults))
setmetatable( t, NGCPRecentCalls_MT ) setmetatable( t, NGCPRecentCalls_MT )
return t return t
@ -52,7 +52,7 @@ end
function NGCPRecentCalls.init(config) function NGCPRecentCalls.init(config)
return { return {
config = config, config = config,
redis = NGCPRedis.new(config.central) redis = NGCPRedis:new(config.central)
} }
end end

@ -36,7 +36,7 @@ NGCPRedis.__tostring = function (t)
return string.format("config:%s", utable.tostring(t.config)) return string.format("config:%s", utable.tostring(t.config))
end end
function NGCPRedis.new(config) function NGCPRedis:new(config)
local t = NGCPRedis:create() local t = NGCPRedis:create()
t.config = utils.merge_defaults(config, defaults) t.config = utils.merge_defaults(config, defaults)
return t; return t;

@ -385,7 +385,7 @@ local Stack_MT = {
} }
-- Create a Table with stack functions -- Create a Table with stack functions
function Stack.new() function Stack:new()
local t = { _et = {} } local t = { _et = {} }
setmetatable(t, Stack_MT) setmetatable(t, Stack_MT)
return t return t

@ -51,7 +51,7 @@ local args = parser:parse()
get_config() get_config()
local dlg = NGCPDlgList.new() local dlg = NGCPDlgList:new()
if dlg_config then if dlg_config then
dlg.config.central.host = dlg_config.central.host dlg.config.central.host = dlg_config.central.host
dlg.config.central.port = dlg_config.central.port dlg.config.central.port = dlg_config.central.port

@ -24,7 +24,7 @@ local hdrMock = require 'mocks.hdr'
-- luacheck: ignore TestHDRMock -- luacheck: ignore TestHDRMock
TestHDRMock = {} TestHDRMock = {}
function TestHDRMock:setUp() function TestHDRMock:setUp()
self.hdr = hdrMock.new() self.hdr = hdrMock:new()
end end
function TestHDRMock:tearDown() function TestHDRMock:tearDown()

@ -24,7 +24,7 @@ local ksrMock = require 'mocks.ksr'
-- luacheck: ignore TestKEMIMock -- luacheck: ignore TestKEMIMock
TestKEMIMock = {} TestKEMIMock = {}
function TestKEMIMock:setUp() function TestKEMIMock:setUp()
self.KSR = ksrMock.new() self.KSR = ksrMock:new()
end end
function TestKEMIMock:test_hdr_get() function TestKEMIMock:test_hdr_get()

@ -25,8 +25,8 @@ local pvMock = require 'mocks.pv'
-- luacheck: ignore TestPVMock -- luacheck: ignore TestPVMock
TestPVMock = {} TestPVMock = {}
function TestPVMock:setUp() function TestPVMock:setUp()
local hdr = hdrMock.new() local hdr = hdrMock:new()
self.pv = pvMock.new(hdr) self.pv = pvMock:new(hdr)
end end
function TestPVMock:tearDown() function TestPVMock:tearDown()

@ -25,8 +25,8 @@ local pvxMock = require 'mocks.pvx'
-- luacheck: ignore TestPVXMock -- luacheck: ignore TestPVXMock
TestPVXMock = {} TestPVXMock = {}
function TestPVXMock:setUp() function TestPVXMock:setUp()
self.pv = pvMock.new() self.pv = pvMock:new()
self.pvx = pvxMock.new(self.pv) self.pvx = pvxMock:new(self.pv)
self.pv.sets("$xavp(test=>uno)", "uno") self.pv.sets("$xavp(test=>uno)", "uno")
lu.assertEquals(self.pv.get("$xavp(test[0]=>uno)"), "uno") lu.assertEquals(self.pv.get("$xavp(test[0]=>uno)"), "uno")

@ -29,7 +29,7 @@ local utils = require 'ngcp.utils'
local utable = utils.table local utable = utils.table
local ksrMock = require 'mocks.ksr' local ksrMock = require 'mocks.ksr'
KSR = ksrMock.new() KSR = ksrMock:new()
local mc,env local mc,env
local dp_vars = DPFetch:new() local dp_vars = DPFetch:new()

@ -36,7 +36,7 @@ TestNGCPAPIClient = {} --class
local NGCPAPIClient = require 'ngcp.api_client' local NGCPAPIClient = require 'ngcp.api_client'
self.client = NGCPAPIClient.new() self.client = NGCPAPIClient:new()
lu.assertNotNil(self.client) lu.assertNotNil(self.client)
self.client.c = self.c; self.client.c = self.c;

@ -21,7 +21,7 @@ local lu = require('luaunit')
local ksrMock = require 'mocks.ksr' local ksrMock = require 'mocks.ksr'
local NGCPAvp = require 'ngcp.avp' local NGCPAvp = require 'ngcp.avp'
KSR = ksrMock.new() KSR = ksrMock:new()
-- luacheck: ignore TestNGCPAvp -- luacheck: ignore TestNGCPAvp
TestNGCPAvp = {} --class TestNGCPAvp = {} --class

@ -22,7 +22,7 @@ local lemock = require('lemock')
local CPFetch = require 'tests_v.cp_vars' local CPFetch = require 'tests_v.cp_vars'
local ksrMock = require 'mocks.ksr' local ksrMock = require 'mocks.ksr'
KSR = ksrMock.new() KSR = ksrMock:new()
local mc,env,con local mc,env,con
local cp_vars = CPFetch:new() local cp_vars = CPFetch:new()

@ -36,7 +36,7 @@ TestNGCPDlgCnt = {} --class
package.loaded.redis = self.fake_redis package.loaded.redis = self.fake_redis
local NGCPDlg = require 'ngcp.dlgcnt' local NGCPDlg = require 'ngcp.dlgcnt'
self.dlg = NGCPDlg.new() self.dlg = NGCPDlg:new()
lu.assertEvalToTrue(self.dlg) lu.assertEvalToTrue(self.dlg)
self.dlg.central.client = self.central; self.dlg.central.client = self.central;

@ -38,7 +38,7 @@ function TestNGCPDlgList:setUp()
package.loaded.redis = self.fake_redis package.loaded.redis = self.fake_redis
local NGCPDlgList = require 'ngcp.dlglist' local NGCPDlgList = require 'ngcp.dlglist'
self.dlg = NGCPDlgList.new() self.dlg = NGCPDlgList:new()
lu.assertEvalToTrue(self.dlg) lu.assertEvalToTrue(self.dlg)
self.dlg.central.client = self.central; self.dlg.central.client = self.central;

@ -24,7 +24,7 @@ local lemock = require('lemock')
local DPFetch = require 'tests_v.dp_vars' local DPFetch = require 'tests_v.dp_vars'
local ksrMock = require 'mocks.ksr' local ksrMock = require 'mocks.ksr'
KSR = ksrMock.new() KSR = ksrMock:new()
local mc,env,con local mc,env,con
local dp_vars = DPFetch:new() local dp_vars = DPFetch:new()

@ -22,7 +22,7 @@ local lemock = require('lemock')
local FPFetch = require 'tests_v.fp_vars' local FPFetch = require 'tests_v.fp_vars'
local ksrMock = require 'mocks.ksr' local ksrMock = require 'mocks.ksr'
KSR = ksrMock.new() KSR = ksrMock:new()
local mc,env,con local mc,env,con
local fp_vars = FPFetch:new() local fp_vars = FPFetch:new()

@ -37,7 +37,7 @@ function TestNGCPLoop:setUp()
package.loaded.redis = self.fake_redis package.loaded.redis = self.fake_redis
local NGCPLoop = require 'ngcp.loop' local NGCPLoop = require 'ngcp.loop'
self.loop = NGCPLoop.new() self.loop = NGCPLoop:new()
lu.assertNotNil(self.loop) lu.assertNotNil(self.loop)
self.loop.redis.client = self.client; self.loop.redis.client = self.client;

@ -25,7 +25,7 @@ local PPFetch = require 'tests_v.pp_vars'
local ksrMock = require 'mocks.ksr' local ksrMock = require 'mocks.ksr'
KSR = ksrMock.new() KSR = ksrMock:new()
local mc,env,con local mc,env,con
local pp_vars = PPFetch:new() local pp_vars = PPFetch:new()

@ -22,7 +22,7 @@ local lemock = require('lemock')
local PProfFetch = require 'tests_v.pprof_vars' local PProfFetch = require 'tests_v.pprof_vars'
local ksrMock = require 'mocks.ksr' local ksrMock = require 'mocks.ksr'
KSR = ksrMock.new() KSR = ksrMock:new()
local mc,env,con local mc,env,con
local pprof_vars = PProfFetch:new() local pprof_vars = PProfFetch:new()

@ -21,7 +21,7 @@ local lu = require('luaunit')
local NGCPPrefs = require 'ngcp.pref' local NGCPPrefs = require 'ngcp.pref'
-- luacheck: globals KSR -- luacheck: globals KSR
local ksrMock = require 'mocks.ksr' local ksrMock = require 'mocks.ksr'
KSR = ksrMock.new() KSR = ksrMock:new()
-- luacheck: ignore TestNGCPPrefs -- luacheck: ignore TestNGCPPrefs
TestNGCPPrefs = {} --class TestNGCPPrefs = {} --class

@ -37,7 +37,7 @@ TestNGCPRecentCalls = {} --class
package.loaded.redis = self.fake_redis package.loaded.redis = self.fake_redis
local NGCPRecentCalls = require 'ngcp.recentcalls' local NGCPRecentCalls = require 'ngcp.recentcalls'
self.rcalls = NGCPRecentCalls.new() self.rcalls = NGCPRecentCalls:new()
lu.assertNotNil(self.rcalls) lu.assertNotNil(self.rcalls)
lu.assertNotNil(self.rcalls.redis) lu.assertNotNil(self.rcalls.redis)
lu.assertNotNil(self.rcalls.redis.config) lu.assertNotNil(self.rcalls.redis.config)
@ -46,7 +46,7 @@ TestNGCPRecentCalls = {} --class
function TestNGCPRecentCalls:test_config() function TestNGCPRecentCalls:test_config()
local NGCPRecentCalls = require 'ngcp.recentcalls' local NGCPRecentCalls = require 'ngcp.recentcalls'
rcalls = NGCPRecentCalls.new({central = {db = 10}}) rcalls = NGCPRecentCalls:new({central = {db = 10}})
lu.assertEquals(rcalls.config.central.db, 10) lu.assertEquals(rcalls.config.central.db, 10)
lu.assertNotNil(rcalls.config.central.port) lu.assertNotNil(rcalls.config.central.port)
end end

@ -41,7 +41,7 @@ TestNGCPRedis = {} --class
package.loaded.redis = self.fake_redis package.loaded.redis = self.fake_redis
local NGCPRedis = require 'ngcp.redis' local NGCPRedis = require 'ngcp.redis'
self.ngcp_redis = NGCPRedis.new() self.ngcp_redis = NGCPRedis:new()
lu.assertNotNil(self.ngcp_redis) lu.assertNotNil(self.ngcp_redis)
lu.assertNotNil(self.ngcp_redis.config) lu.assertNotNil(self.ngcp_redis.config)
self.ngcp_redis.client = self.client; self.ngcp_redis.client = self.client;

@ -24,7 +24,7 @@ local NGCPPeerPrefs = require 'ngcp.pp'
local NGCPRealPrefs = require 'ngcp.rp' local NGCPRealPrefs = require 'ngcp.rp'
local ksrMock = require 'mocks.ksr' local ksrMock = require 'mocks.ksr'
KSR = ksrMock.new() KSR = ksrMock:new()
-- luacheck: ignore TestNGCPRealPrefs -- luacheck: ignore TestNGCPRealPrefs
TestNGCPRealPrefs = {} --class TestNGCPRealPrefs = {} --class

@ -25,7 +25,7 @@ local UPFetch = require 'tests_v.up_vars'
local bp_vars = require 'tests_v.bp_vars' local bp_vars = require 'tests_v.bp_vars'
local ksrMock = require 'mocks.ksr' local ksrMock = require 'mocks.ksr'
KSR = ksrMock.new() KSR = ksrMock:new()
local mc,env,con local mc,env,con
local up_vars = UPFetch:new() local up_vars = UPFetch:new()

@ -21,7 +21,7 @@ local lu = require('luaunit')
local NGCPXAvp = require 'ngcp.xavp' local NGCPXAvp = require 'ngcp.xavp'
local ksrMock = require 'mocks.ksr' local ksrMock = require 'mocks.ksr'
KSR = ksrMock.new() KSR = ksrMock:new()
local vals = { local vals = {
{ {

@ -22,7 +22,7 @@ local NGCPXAvp = require 'ngcp.xavp'
local NGCPAvp = require 'ngcp.avp' local NGCPAvp = require 'ngcp.avp'
local ksrMock = require 'mocks.ksr' local ksrMock = require 'mocks.ksr'
KSR = ksrMock.new() KSR = ksrMock:new()
-- luacheck: ignore TestUseCases -- luacheck: ignore TestUseCases
TestUseCases = {} TestUseCases = {}

@ -24,7 +24,7 @@ local Stack = utils.Stack
-- luacheck: ignore TestStack -- luacheck: ignore TestStack
TestStack = {} TestStack = {}
function TestStack:test() function TestStack:test()
local s = Stack.new() local s = Stack:new()
lu.assertEquals(type(s), 'table') lu.assertEquals(type(s), 'table')
lu.assertEquals(s.__class__, 'Stack') lu.assertEquals(s.__class__, 'Stack')
end end

@ -50,7 +50,7 @@ local CPFetch = {
__class__ = 'CPFetch', __class__ = 'CPFetch',
_i = 1 _i = 1
} }
function CPFetch.new() function CPFetch:new()
local t = {} local t = {}
return setmetatable(t, { __index = CPFetch }) return setmetatable(t, { __index = CPFetch })
end end

@ -171,7 +171,7 @@ local DPFetch = {
__class__ = 'DPFetch', __class__ = 'DPFetch',
_i = 1 _i = 1
} }
function DPFetch.new() function DPFetch:new()
local t = {} local t = {}
return setmetatable(t, { __index = DPFetch }) return setmetatable(t, { __index = DPFetch })
end end

@ -51,7 +51,7 @@ local fp_vars = {
local FPFetch = { local FPFetch = {
__class__ = 'FPFetch', __class__ = 'FPFetch',
} }
function FPFetch.new() function FPFetch:new()
local t = {} local t = {}
return setmetatable(t, { __index = FPFetch }) return setmetatable(t, { __index = FPFetch })
end end

@ -178,7 +178,7 @@ local PPFetch = {
__class__ = 'PPFetch', __class__ = 'PPFetch',
_i = 1 _i = 1
} }
function PPFetch.new() function PPFetch:new()
local t = {} local t = {}
return setmetatable(t, { __index = PPFetch }) return setmetatable(t, { __index = PPFetch })
end end

@ -178,7 +178,7 @@ local PProfFetch = {
__class__ = 'PProfFetch', __class__ = 'PProfFetch',
_i = 1 _i = 1
} }
function PProfFetch.new() function PProfFetch:new()
local t = {} local t = {}
return setmetatable(t, { __index = PProfFetch }) return setmetatable(t, { __index = PProfFetch })
end end

@ -162,7 +162,7 @@ local UPFetch = {
__class__ = 'UPFetch', __class__ = 'UPFetch',
_i = 1 _i = 1
} }
function UPFetch.new() function UPFetch:new()
local t = {} local t = {}
return setmetatable(t, { __index = UPFetch }) return setmetatable(t, { __index = UPFetch })
end end

Loading…
Cancel
Save