summaryrefslogtreecommitdiffstats
path: root/conf.d/controller/lua.d
diff options
context:
space:
mode:
authorCorentin Le Gall <corentinlgs@gmail.com>2018-07-23 13:55:25 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-07-26 10:19:48 +0200
commit99e5c662eb4c5819e082d955da963a6db21c0e0a (patch)
treea0a920ff52ce6f80a0d122a2b8cb534b01862858 /conf.d/controller/lua.d
parent7df6f7dd70ffc7f073e466cc7e3788276c148e2e (diff)
Fixed bugs on EvtGrpReceived functions
-Changed event.name to eventName and added a condition in _AFT.triggerEvtCallback. -Added tests functions to assertEvtGrpReceived functions. -Corrected a mistake in _AFT.assertEvtGrpNotReceived. Change-Id: Ic0f72ac9789f5056dd628d950fa53f54b3a82112 Signed-off-by: Corentin Le Gall <corentinlgs@gmail.com>
Diffstat (limited to 'conf.d/controller/lua.d')
-rw-r--r--conf.d/controller/lua.d/aft.lua27
-rw-r--r--conf.d/controller/lua.d/helloworld.lua7
2 files changed, 26 insertions, 8 deletions
diff --git a/conf.d/controller/lua.d/aft.lua b/conf.d/controller/lua.d/aft.lua
index f0c7388..4d0fac7 100644
--- a/conf.d/controller/lua.d/aft.lua
+++ b/conf.d/controller/lua.d/aft.lua
@@ -108,11 +108,13 @@ end
function _AFT.triggerEvtCallback(eventName)
if _AFT.monitored_events[eventName].cb then
- local data_n = table_size(_AFT.monitored_events[event.name].data)
- if _AFT.event_history == true then
- _AFT.monitored_events[event.name].cb(v.name, _AFT.monitored_events[event.name].data[data_n], _AFT.monitored_events[event.name].data)
- else
- _AFT.monitored_events[event.name].cb(v.name, _AFT.monitored_events[event.name].data[data_n])
+ if _AFT.monitored_events[eventName].data ~= nil then
+ local data_n = table_size(_AFT.monitored_events[eventName].data)
+ if _AFT.event_history == true then
+ _AFT.monitored_events[eventName].cb(v.name, _AFT.monitored_events[eventName].data[data_n], _AFT.monitored_events[eventName].data)
+ else
+ _AFT.monitored_events[eventName].cb(v.name, _AFT.monitored_events[eventName].data[data_n])
+ end
end
end
end
@@ -204,7 +206,7 @@ end
function _AFT.assertEvtGrpNotReceived(eventGroup, timeout)
local count = 0
local eventName = ""
- for _,event in pairs(eventGroup) do
+ for key,event in pairs(eventGroup) do
eventGroup[key] = {name = event, receivedCount = _AFT.monitored_events[event].receivedCount}
end
@@ -251,6 +253,19 @@ function _AFT.assertEvtGrpReceived(eventGroup, timeout)
end
end
+function _AFT.testEvtGrpReceived(testName, eventGroup, timeout, setUp, tearDown)
+ _AFT.describe(testName, function()
+ _AFT.assertEvtGrpReceived(eventGroup, timeout)
+ end, setUp, tearDown)
+end
+
+function _AFT.testEvtGrpNotReceived(testName, eventGroup, timeout, setUp, tearDown)
+ _AFT.describe(testName, function()
+ _AFT.assertEvtGrpNotReceived(eventGroup, timeout)
+ end, setUp, tearDown)
+end
+
+
function _AFT.assertEvtNotReceived(eventName, timeout)
local count = _AFT.monitored_events[eventName].receivedCount
if timeout then
diff --git a/conf.d/controller/lua.d/helloworld.lua b/conf.d/controller/lua.d/helloworld.lua
index 8fcf077..bffb230 100644
--- a/conf.d/controller/lua.d/helloworld.lua
+++ b/conf.d/controller/lua.d/helloworld.lua
@@ -55,5 +55,8 @@ _AFT.testVerbStatusSuccess('testEventPushanotherEvent', 'hello', 'eventpush', {t
_AFT.testVerbStatusSuccess('testGenerateWarning', 'hello', 'verbose', {level = 4, message = 'My Warning message!'})
-_AFT.testEvtReceived("testanEventReceived", "hello/anEvent",3000000)
-_AFT.testEvtReceived("testanotherEventReceived", "hello/anotherEvent",3000000)
+_AFT.testEvtGrpReceived("testEventGroupReceived",{"hello/anEvent","hello/anotherEvent"},300000)
+_AFT.testEvtGrpNotReceived("testEventGroupNotReceived",{"hello/anEvent","hello/anotherEvent"},300000)
+
+_AFT.testEvtReceived("testanEventReceived", "hello/anEvent",300000)
+_AFT.testEvtReceived("testanotherEventReceived", "hello/anotherEvent",300000)