aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-09-27 11:25:14 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-09-27 13:05:37 +0200
commitfe8f535a3544f3d828c6128d52591c5d194b693e (patch)
tree1ec95acc1fd3dd58c90a293e14b19c776b84b6ee /test
parent54aaf898304ff0c2c6439d3cb4da415e97e07857 (diff)
Add tests on sources injection at runtime
This adds some basic tests about adding dummy sources into the signal composer in addition of signals. Change-Id: I028faa612b749866a3ab986a2f46fe00dd2d7884 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'test')
-rw-r--r--test/afb-test/fixtures/source.json8
-rw-r--r--test/afb-test/fixtures/sources_invalid.json13
-rw-r--r--test/afb-test/tests/signal-composer_BasicAPITest.lua62
3 files changed, 83 insertions, 0 deletions
diff --git a/test/afb-test/fixtures/source.json b/test/afb-test/fixtures/source.json
new file mode 100644
index 0000000..817874f
--- /dev/null
+++ b/test/afb-test/fixtures/source.json
@@ -0,0 +1,8 @@
+{
+ "$schema": "http://iot.bzh/download/public/schema/json/signal-composer-schema.json",
+ "sources": {
+ "uid": "Dummy_Source",
+ "api": "dummy",
+ "info": "A dummy source to be used as test source"
+ }
+ }
diff --git a/test/afb-test/fixtures/sources_invalid.json b/test/afb-test/fixtures/sources_invalid.json
new file mode 100644
index 0000000..e7388aa
--- /dev/null
+++ b/test/afb-test/fixtures/sources_invalid.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "http://iot.bzh/download/public/schema/json/signal-composer-schema.json",
+ "sources": [
+ {
+ "uid": "MissingFieldSource",
+ "info": "A dummy source to be used as test source",
+ },{
+ "uid": "InvalidFieldSource",
+ "api": "anotherDummySource",
+ "retention": "A dummy source to be used as test source",
+ }
+ ]
+ }
diff --git a/test/afb-test/tests/signal-composer_BasicAPITest.lua b/test/afb-test/tests/signal-composer_BasicAPITest.lua
index fe8a78c..61ef167 100644
--- a/test/afb-test/tests/signal-composer_BasicAPITest.lua
+++ b/test/afb-test/tests/signal-composer_BasicAPITest.lua
@@ -107,6 +107,68 @@ _AFT.testVerbStatusError(testPrefix.."getFilterInvalidSecondArgument","signal-co
--[[
################################################################################
+########################### Adding new sources #################################
+################################################################################
+]]
+
+---------------------------
+-- Successful verb calls --
+---------------------------
+
+--[[ This tests the 'addObjects' verb of the signal-composer API, this is by passing the path of a json containing sources
+ then making a get, a subscribe, and an unsubscribe looking for any misbehaviour from sources added with the verb ]]
+_AFT.describe(testPrefix.."addSourcesByFile", function()
+ _AFT.assertVerbStatusSuccess("signal-composer", "addObjects", {file = _AFT.bindingRootDir.."/var/source.json"})
+end);
+
+-- This tests the 'addObjects' verb of the signal-composer API, this is by passing directly the json object as a lua table
+_AFT.testVerbStatusSuccess(testPrefix.."addSourcesDirect","signal-composer","addObjects",
+ {
+ sources = {
+ uid = "DummySource2",
+ api = "dummy2",
+ info = "Another dummy source to be used as test source",
+ }
+ }
+);
+
+-----------------------
+-- Failed verb calls --
+-----------------------
+
+--[[ This tests the 'addObjects' verb of the signal-composer API, this is by passing directly the json object as a lua table.
+ This one has invalid doesn't specified the required api field which should fails the assertion]]
+_AFT.testVerbStatusError(testPrefix.."addSourcesDirect_InvalidSource","signal-composer","addObjects",
+ {
+ sources = {
+ {
+ uid = "invalidSource",
+ info = "An invalid source without Api specified",
+ }
+ }
+ }
+);
+
+--[[ This tests the 'addObjects' verb of the signal-composer API, this is by passing directly the json object as a lua table.
+ This one has a wrong retention field ]]
+_AFT.testVerbStatusError(testPrefix.."addSourcesDirect_MissingField","signal-composer","addObjects",
+ {
+ sources= {
+ {
+ api = "invalidSource3",
+ info = "An invalid source without UID specified",
+ retention = "Invalid retention"
+ }
+ }
+ }
+);
+
+--[[ This tests the 'addObjects' verb of the signal-composer API, this is by passing the path of a json containing sources
+ This one has invalid values for most of its field, the binding should not be able to add it ]]
+_AFT.testVerbStatusError(testPrefix.."addSourcesByFile_InvalidSources","signal-composer","addObjects",{file = _AFT.bindingRootDir.."/var/sources_invalid.json"});
+
+--[[
+################################################################################
########################### Adding new signals #################################
################################################################################
]]