diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-06-14 01:09:27 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-07-10 17:12:13 +0200 |
commit | 4f54455b5cd4841b6f905bbe6e2530f9e22a11a7 (patch) | |
tree | 1f174cbe87082ef5a4e823646c4eb7c78775bf5d /conf.d/project/lua.d/helloworld.lua | |
parent | 8f91a2c2dfa8535a2bae5854648138de4abe7f65 (diff) |
Implement event part of test framework
Change-Id: I77151a668f89671e0391a90be2559d61dc0e5ec4
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'conf.d/project/lua.d/helloworld.lua')
-rw-r--r-- | conf.d/project/lua.d/helloworld.lua | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/conf.d/project/lua.d/helloworld.lua b/conf.d/project/lua.d/helloworld.lua index 81024bc..ccb1c67 100644 --- a/conf.d/project/lua.d/helloworld.lua +++ b/conf.d/project/lua.d/helloworld.lua @@ -18,7 +18,37 @@ NOTE: strict mode: every global variables should be prefixed by '_' --]] -local AFT = require('aft') +function _callback(responseJ) + _AFT.assertStrContains(responseJ.response, "Some String") +end ---print("***** In Helloworld Test ".. Dump_Table(AFT)) -AFT.assertVerbStatusSuccess('hello', 'ping', {}) +function _callbackError(responseJ) + _AFT.assertStrContains(responseJ.request.info, "Ping Binder Daemon fails") +end + +function _callbackEvent(eventName, eventData) + _AFT.assertEquals(eventData, {data = { key = 'weird others data', another_key = 123.456 }}) +end + +_AFT.addEventToMonitor("hello/anEvent") +_AFT.addEventToMonitor("hello/anotherEvent", _callbackEvent) + +_AFT.testVerbStatusSuccess('testPingSuccess','hello', 'ping', {}) +_AFT.testVerbResponseEquals('testPingSuccess','hello', 'ping', {}, "Some String") +_AFT.testVerbResponseEquals('testPingSuccess','hello', 'ping', {}, "Unexpected String") +_AFT.testVerbCb('testPingSuccess','hello', 'ping', {}, _callback) +_AFT.testVerbStatusError('testPingError', 'hello', 'pingfail', {}) +_AFT.testVerbResponseEqualsError('testPingError', 'hello', 'pingfail', {}, "Ping Binder Daemon fails") +_AFT.testVerbResponseEqualsError('testPingError', 'hello', 'pingfail', {}, "Ping Binder Daemon succeed") +_AFT.testVerbCbError('testPingError', 'hello', 'pingfail', {}, _callbackError) + +_AFT.testVerbStatusSuccess('testEventAdd', 'hello', 'eventadd', {tag = 'event', name = 'anEvent'}) +_AFT.testVerbStatusSuccess('testEventSub', 'hello', 'eventsub', {tag = 'event'}) +_AFT.testVerbStatusSuccess('testEventPush', 'hello', 'eventpush', {tag = 'event', data = { key = 'some data', another_key = 123}}) + +_AFT.testVerbStatusSuccess('testEventAdd', 'hello', 'eventadd', {tag = 'evt', name = 'anotherEvent'}) +_AFT.testVerbStatusSuccess('testEventSub', 'hello', 'eventsub', {tag = 'evt'}) +_AFT.testVerbStatusSuccess('testEventPush', 'hello', 'eventpush', {tag = 'evt', data = { key = 'weird others data', another_key = 123.456}}) + +_AFT.testEvtReceived("testEvent", "hello/anEvent") +_AFT.testEvtReceived("testEventCb", "hello/anotherEvent") |