diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-09-16 14:21:26 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-10-10 10:53:47 +0200 |
commit | 79bb6f3be1303025a2ed3914c5012ab2c9c08f73 (patch) | |
tree | e7959b1f3049e679fee1abf7c56e06cc5e823538 /conf.d/controller/lua.d | |
parent | c2271569bf1dd72b5fe6aaa110328dc0850c2088 (diff) |
Assert that an event hasn't been received
Change-Id: I594c31238a0afc47f90cc97be82f3044a5052d67
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'conf.d/controller/lua.d')
-rw-r--r-- | conf.d/controller/lua.d/aft.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/conf.d/controller/lua.d/aft.lua b/conf.d/controller/lua.d/aft.lua index aabeb93..a76bf45 100644 --- a/conf.d/controller/lua.d/aft.lua +++ b/conf.d/controller/lua.d/aft.lua @@ -226,6 +226,30 @@ end Assert and test functions about the event part. ]] +function _AFT.assertEvtGrpNotReceived(eventGroup, timeout) + local count = 0 + local expected = 0 + local eventName = "" + + if timeout then + count = _AFT.lockWaitGroup(eventGroup, timeout) + else + for event in pairs(eventGroup) do + count = count + _AFT.monitored_events[event].receivedCount + end + end + + for event,expectedCount in pairs(eventGroup) do + eventName = eventName .. " " .. event + expected = expected + expectedCount + end + _AFT.assertIsTrue(count <= expected, "One of the following events has been received: '".. eventName .."' but it shouldn't") + + for event in pairs(eventGroup) do + _AFT.triggerEvtCallback(event) + end + end + function _AFT.assertEvtGrpReceived(eventGroup, timeout) local count = 0 local expected = 0 @@ -251,6 +275,17 @@ function _AFT.assertEvtGrpReceived(eventGroup, timeout) end end +function _AFT.assertEvtNotReceived(eventName, timeout) + local count = _AFT.monitored_events[eventName].receivedCount + if timeout then + count = _AFT.lockWait(eventName, timeout) + end + + _AFT.assertIsTrue(count == 0, "Event '".. eventName .."' received but it shouldn't") + + _AFT.triggerEvtCallback(eventName) + end + function _AFT.assertEvtReceived(eventName, timeout) local count = _AFT.monitored_events[eventName].receivedCount if timeout then |