aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--signal-composer-binding/signal-composer-binding.cpp18
-rw-r--r--test/afb-test/tests/signal-composer_BasicAPITest.lua4
2 files changed, 14 insertions, 8 deletions
diff --git a/signal-composer-binding/signal-composer-binding.cpp b/signal-composer-binding/signal-composer-binding.cpp
index a9be63e..234888c 100644
--- a/signal-composer-binding/signal-composer-binding.cpp
+++ b/signal-composer-binding/signal-composer-binding.cpp
@@ -181,9 +181,17 @@ void addObjects(afb_req request)
if(!objectsJ)
{
json_object* responseJ = ScanForConfig(CONTROL_CONFIG_PATH, CTL_SCAN_RECURSIVE, filepath, ".json");
- filepath = ConfigSearch(nullptr, responseJ);
- if(filepath)
- {objectsJ = json_object_from_file(filepath);}
+ if(responseJ)
+ {
+ filepath = ConfigSearch(nullptr, responseJ);
+ if(filepath)
+ {objectsJ = json_object_from_file(filepath);}
+ }
+ else
+ {
+ afb_req_fail_f(request, "Fail to find file: %s", filepath);
+ return;
+ }
}
}
else
@@ -194,10 +202,9 @@ void addObjects(afb_req request)
json_object_object_get_ex(objectsJ, "sources", &sourcesJ);
json_object_object_get_ex(objectsJ, "signals", &signalsJ);
- if( sourcesJ && composer.loadSources(sourcesJ))
+ if(sourcesJ && composer.loadSources(sourcesJ))
{
afb_req_fail_f(request, "Loading 'sources' configuration or subscription error", "Error code: -2");
- json_object_put(objectsJ);
return;
}
if(signalsJ)
@@ -207,7 +214,6 @@ void addObjects(afb_req request)
else
{
afb_req_fail_f(request, "Loading 'signals' configuration or subscription error", "Error code: -2");
- json_object_put(objectsJ);
return;
}
}
diff --git a/test/afb-test/tests/signal-composer_BasicAPITest.lua b/test/afb-test/tests/signal-composer_BasicAPITest.lua
index 8e9e212..b5ebb62 100644
--- a/test/afb-test/tests/signal-composer_BasicAPITest.lua
+++ b/test/afb-test/tests/signal-composer_BasicAPITest.lua
@@ -61,7 +61,7 @@ _AFT.testVerbStatusSuccess(testPrefix.."getFilterMax","signal-composer","get",{s
--[[ This tests the 'addObjects' verb of the signal-composer API, this is by passing the path of a json containing signals
then making a get, a subscribe, and an unsubscribe looking for any misbehaviour from signals added with the verb ]]
_AFT.describe(testPrefix.."addObjectsByFile",function()
- _AFT.assertVerbStatusSuccess("signal-composer","addObjects",{file = _AFT.bindingRootDir.."var/sig_test.json"})
+ _AFT.assertVerbStatusSuccess("signal-composer","addObjects",{file = _AFT.bindingRootDir.."/var/sig_test.json"})
_AFT.assertVerbStatusSuccess("signal-composer","get",{signal= "vehicle_speedTest1",options= {average=10}});
_AFT.assertVerbStatusSuccess("signal-composer","subscribe",{ signal = "vehicle_speedTest1"});
_AFT.assertVerbStatusSuccess("signal-composer","unsubscribe",{ signal = "vehicle_speedTest1"});
@@ -181,4 +181,4 @@ _AFT.testVerbStatusError(testPrefix.."getFilterInvalidFirstArgument","signal-com
-- This tests the 'get' verb of the signal-composer API, with an invalid second parameter name, it should reply with an error
_AFT.testVerbStatusError(testPrefix.."getFilterInvalidSecondArgument","signal-composer","get",{signal= "vehicule_speed", notValidAtAll= {average= 10}});
-_AFT.exitAtEnd(); \ No newline at end of file
+_AFT.exitAtEnd();