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
(cherry picked from commit a06903a0e3)
mr10.5.2
Victor Seva 3 years ago
parent dd3c62fbc1
commit a49f8a3915

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -25,8 +25,8 @@ local pvxMock = require 'mocks.pvx'
-- luacheck: ignore TestPVXMock
TestPVXMock = {}
function TestPVXMock:setUp()
self.pv = pvMock.new()
self.pvx = pvxMock.new(self.pv)
self.pv = pvMock:new()
self.pvx = pvxMock:new(self.pv)
self.pv.sets("$xavp(test=>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 ksrMock = require 'mocks.ksr'
KSR = ksrMock.new()
KSR = ksrMock:new()
local mc,env
local dp_vars = DPFetch:new()

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

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

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

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

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

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

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

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

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

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

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

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

@ -41,7 +41,7 @@ TestNGCPRedis = {} --class
package.loaded.redis = self.fake_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.config)
self.ngcp_redis.client = self.client;

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save