1
0
Fork 0
This commit is contained in:
Jan Steemann 2013-05-06 09:40:28 +02:00
parent 203aceccdf
commit ede177aa55
6 changed files with 114 additions and 24 deletions

View File

@ -1,6 +1,10 @@
v1.3.0 (2013-05-XX) v1.3.0 (2013-05-XX)
------------------- -------------------
* issue #508: `unregistergroup` function not mentioned in http interface docs
* issue #507: GET /_api/aqlfunction returns code inside parentheses
* fixed issue #489: Bug in aal.install * fixed issue #489: Bug in aal.install
* fixed issue 505: statistics not populated on MacOS * fixed issue 505: statistics not populated on MacOS

View File

@ -223,10 +223,10 @@ ALIASES += \
"RESTRETURNCODE{1}=@htmlonly<div class=\"restreturncode\">HTTP \1</div>@endhtmlonly" \ "RESTRETURNCODE{1}=@htmlonly<div class=\"restreturncode\">HTTP \1</div>@endhtmlonly" \
"RESTDESCRIPTION=@htmlonly<div class=\"restdescription\">Description</div>@endhtmlonly" \ "RESTDESCRIPTION=@htmlonly<div class=\"restdescription\">Description</div>@endhtmlonly" \
"RESTURLPARAMETERS=@htmlonly<div class=\"resturlparameters\">URL parameters</div>@endhtmlonly" \ "RESTURLPARAMETERS=@htmlonly<div class=\"resturlparameters\">URL parameters</div>@endhtmlonly" \
"RESTURLPARAM{3}=@htmlonly<div class=\"resturlparam\">URL parameter</div>@endhtmlonly" \ "RESTURLPARAM{3}=@htmlonly<div class=\"resturlparam\">@endhtmlonly\1 (\2,\3)@htmlonly</div>@endhtmlonly" \
"RESTHEADERPARAMETERS=@htmlonly<div class=\"restheaderparameters\">HTTP header parameters</div>@endhtmlonly" \ "RESTHEADERPARAMETERS=@htmlonly<div class=\"restheaderparameters\">HTTP header parameters</div>@endhtmlonly" \
"RESTHEADERPARAM{3}=@htmlonly<div class=\"restheaderparam\">HTTP header</div>@endhtmlonly" \ "RESTHEADERPARAM{3}=@htmlonly<div class=\"restheaderparam\">@endhtmlonly\1 (\2,\3)@htmlonly</div>@endhtmlonly" \
"RESTBODYPARAM{3}=@htmlonly<div class=\"restbodyparam\">HTTP body parameter</div>@endhtmlonly" \ "RESTBODYPARAM{3}=@htmlonly<div class=\"restbodyparam\">@endhtmlonly\1 (\2,\3)@htmlonly</div>@endhtmlonly" \
"RESTDOCUMENTATION=@htmlonly<div class=\"restdocumentation\">REST documentation</div>@endhtmlonly" "RESTDOCUMENTATION=@htmlonly<div class=\"restdocumentation\">REST documentation</div>@endhtmlonly"
# navigation # navigation

View File

@ -96,7 +96,7 @@ describe ArangoDB do
## adding and deleting functions ## adding and deleting functions
################################################################################ ################################################################################
context "adding functions" do context "adding and deleting functions" do
before do before do
ArangoDB.delete("/_api/aqlfunction/UnitTests%3Amytest") ArangoDB.delete("/_api/aqlfunction/UnitTests%3Amytest")
end end
@ -153,36 +153,87 @@ describe ArangoDB do
doc.parsed_response['code'].should eq(404) doc.parsed_response['code'].should eq(404)
doc.parsed_response['errorNum'].should eq(1582) doc.parsed_response['errorNum'].should eq(1582)
end end
it "add function, delete multiple" do
body = "{ \"name\" : \"UnitTests:mytest:one\", \"code\": \"function () { return 1; }\" }"
doc = ArangoDB.log_post("#{prefix}-add-function4", api, :body => body)
doc.code.should eq(201)
body = "{ \"name\" : \"UnitTests:mytest:two\", \"code\": \"function () { return 1; }\" }"
doc = ArangoDB.log_post("#{prefix}-add-function4", api, :body => body)
doc.code.should eq(201)
body = "{ \"name\" : \"UnitTests:foo\", \"code\": \"function () { return 1; }\" }"
doc = ArangoDB.log_post("#{prefix}-add-function4", api, :body => body)
doc.code.should eq(201)
doc = ArangoDB.log_delete("#{prefix}-add-function4", api + "/UnitTests%3Amytest?group=true")
doc.code.should eq(200)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(200)
doc = ArangoDB.log_delete("#{prefix}-add-function4", api + "/UnitTests%3Amytest%3Aone")
doc.code.should eq(404)
doc = ArangoDB.log_delete("#{prefix}-add-function4", api + "/UnitTests%3Amytest%3Atwo")
doc.code.should eq(404)
doc = ArangoDB.log_delete("#{prefix}-add-function4", api + "/UnitTests%3Afoo")
doc.code.should eq(200)
end
end end
################################################################################ ################################################################################
## retrieving the list of functions ## retrieving the list of functions
################################################################################ ################################################################################
context "adding functions" do context "retrieving functions" do
before do before do
ArangoDB.delete("/_api/aqlfunction/UnitTests%3Amytest") ArangoDB.delete("/_api/aqlfunction/UnitTests?group=true")
end end
after do after do
ArangoDB.delete("/_api/aqlfunction/UnitTests%3Amytest") ArangoDB.delete("/_api/aqlfunction/UnitTests?group=true")
end end
it "add function and retrieve the list" do it "add function and retrieve the list" do
body = "{ \"name\" : \"UnitTests:mytest\", \"code\": \"function () { return 1; }\" }" body = "{ \"name\" : \"UnitTests:mytest\", \"code\": \"function () { return 1; }\" }"
doc = ArangoDB.log_post("#{prefix}-list-functions", api, :body => body) doc = ArangoDB.log_post("#{prefix}-list-functions1", api, :body => body)
doc.code.should eq(201) doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8") doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false) doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(201) doc.parsed_response['code'].should eq(201)
doc = ArangoDB.log_get("#{prefix}-list-functions", api + "?prefix=UnitTests") doc = ArangoDB.log_get("#{prefix}-list-functions1", api + "?prefix=UnitTests")
doc.code.should eq(200) doc.code.should eq(200)
doc.headers['content-type'].should eq("application/json; charset=utf-8") doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response.length.should eq(1) doc.parsed_response.length.should eq(1)
doc.parsed_response[0]['name'].should eq("UnitTests:mytest") doc.parsed_response[0]['name'].should eq("UnitTests:mytest")
doc.parsed_response[0]['code'].should eq("function () { return 1; }")
end
it "add functions and retrieve the list" do
body = "{ \"name\" : \"UnitTests:mytest1\", \"code\": \"function () { return 1; }\" }"
doc = ArangoDB.log_post("#{prefix}-list-functions2", api, :body => body)
doc.code.should eq(201)
doc = ArangoDB.log_get("#{prefix}-list-functions2", api + "?prefix=UnitTests")
doc.code.should eq(200)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response.length.should eq(1)
doc.parsed_response[0]['name'].should eq("UnitTests:mytest1")
doc.parsed_response[0]['code'].should eq("function () { return 1; }")
body = "{ \"name\" : \"UnitTests:mytest1\", \"code\": \"( function () { return 3 * 5; } ) \" }"
doc = ArangoDB.log_post("#{prefix}-list-functions2", api, :body => body)
doc.code.should eq(200)
doc = ArangoDB.log_get("#{prefix}-list-functions2", api + "?prefix=UnitTests")
doc.code.should eq(200)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response.length.should eq(1)
doc.parsed_response[0]['name'].should eq("UnitTests:mytest1")
doc.parsed_response[0]['code'].should eq("( function () { return 3 * 5; } ) ")
end end
end end

View File

@ -137,9 +137,18 @@ function POST_api_aqlfunction (req, res) {
/// ///
/// @REST{DELETE /_api/aqlfunction/`name`} /// @REST{DELETE /_api/aqlfunction/`name`}
/// ///
/// @RESTURLPARAMETERS
///
/// @RESTURLPARAM{group,string,optional}
/// If set to `true`, then the function name provided in `name` is treated as
/// a namespace prefix, and all functions in the specified namespace will be deleted.
///
/// If set to `false`, the function name provided in `name` must be fully
/// qualified, including any namespaces.
///
/// @RESTDESCRIPTION
///
/// Removes an existing AQL user function, identified by `name`. /// Removes an existing AQL user function, identified by `name`.
/// The function name provided in `name` must be fully qualified, including
/// any namespaces.
/// ///
/// If the function can be removed by the server, the server will respond with /// If the function can be removed by the server, the server will respond with
/// `HTTP 200`. /// `HTTP 200`.
@ -175,7 +184,13 @@ function DELETE_api_aqlfunction (req, res) {
var name = decodeURIComponent(req.suffix[0]); var name = decodeURIComponent(req.suffix[0]);
try { try {
var g = req.parameters['group'];
if (g === 'true' || g === 'yes' || g === 'y' || g === 'on' || g === '1') {
aqlfunctions.unregisterGroup(name);
}
else {
aqlfunctions.unregister(name); aqlfunctions.unregister(name);
}
actions.resultOk(req, res, actions.HTTP_OK, { }); actions.resultOk(req, res, actions.HTTP_OK, { });
} }
catch (err) { catch (err) {

View File

@ -331,7 +331,7 @@ var toArrayFunctions = function (group) {
var result = [ ]; var result = [ ];
getFiltered(group).forEach(function (f) { getFiltered(group).forEach(function (f) {
result.push({ name: f.name, code: f.code }); result.push({ name: f.name, code: f.code.substr(1, f.code.length - 2) });
}); });
return result; return result;

View File

@ -79,10 +79,10 @@ function AqlFunctionsSuite () {
aqlfunctions.register("UnitTests:tryme:foo", function (what) { return what * 2; }, true); aqlfunctions.register("UnitTests:tryme:foo", function (what) { return what * 2; }, true);
aqlfunctions.register("UnitTests:tryme:bar", function (what) { return what * 2; }, true); aqlfunctions.register("UnitTests:tryme:bar", function (what) { return what * 2; }, true);
assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests").sort().map(function (f) { return f.name; })); assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests").map(function (f) { return f.name; }).sort());
assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests:").sort().map(function (f) { return f.name; })); assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests:").map(function (f) { return f.name; }).sort());
assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests:tryme").sort().map(function (f) { return f.name; })); assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests:tryme").map(function (f) { return f.name; }).sort());
assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests:tryme:").sort().map(function (f) { return f.name; })); assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests:tryme:").map(function (f) { return f.name; }).sort());
}, },
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -95,18 +95,38 @@ function AqlFunctionsSuite () {
aqlfunctions.register("UnitTests58:tryme:bar", function (what) { return what * 2; }, true); aqlfunctions.register("UnitTests58:tryme:bar", function (what) { return what * 2; }, true);
aqlfunctions.register("UnitTests58:whyme:bar", function (what) { return what * 2; }, true); aqlfunctions.register("UnitTests58:whyme:bar", function (what) { return what * 2; }, true);
assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests").sort().map(function (f) { return f.name; })); assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests").map(function (f) { return f.name; }).sort());
assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests:").sort().map(function (f) { return f.name; })); assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests:").map(function (f) { return f.name; }).sort());
assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests:tryme").sort().map(function (f) { return f.name; })); assertEqual([ "UnitTests:tryme:bar", "UnitTests:tryme:foo" ], aqlfunctions.toArray("UnitTests:tryme").map(function (f) { return f.name; }).sort());
assertEqual([ "UnitTests58:tryme:bar", "UnitTests58:whyme:bar" ], aqlfunctions.toArray("UnitTests58").sort().map(function (f) { return f.name; })); assertEqual([ "UnitTests58:tryme:bar", "UnitTests58:whyme:bar" ], aqlfunctions.toArray("UnitTests58").map(function (f) { return f.name; }).sort());
assertEqual([ "UnitTests58:tryme:bar", "UnitTests58:whyme:bar" ], aqlfunctions.toArray("UnitTests58:").sort().map(function (f) { return f.name; })); assertEqual([ "UnitTests58:tryme:bar", "UnitTests58:whyme:bar" ], aqlfunctions.toArray("UnitTests58:").map(function (f) { return f.name; }).sort());
assertEqual([ "UnitTests58:tryme:bar" ], aqlfunctions.toArray("UnitTests58:tryme").sort().map(function (f) { return f.name; })); assertEqual([ "UnitTests58:tryme:bar" ], aqlfunctions.toArray("UnitTests58:tryme").map(function (f) { return f.name; }).sort());
assertEqual([ "UnitTests58:tryme:bar" ], aqlfunctions.toArray("UnitTests58:tryme:").sort().map(function (f) { return f.name; })); assertEqual([ "UnitTests58:tryme:bar" ], aqlfunctions.toArray("UnitTests58:tryme:").map(function (f) { return f.name; }).sort());
aqlfunctions.unregister("UnitTests58:tryme:bar", function (what) { return what * 2; }, true); aqlfunctions.unregister("UnitTests58:tryme:bar", function (what) { return what * 2; }, true);
aqlfunctions.unregister("UnitTests58:whyme:bar", function (what) { return what * 2; }, true); aqlfunctions.unregister("UnitTests58:whyme:bar", function (what) { return what * 2; }, true);
}, },
////////////////////////////////////////////////////////////////////////////////
/// @brief test registered code
////////////////////////////////////////////////////////////////////////////////
testRegisterCode1 : function () {
unregister("UnitTests:tryme");
aqlfunctions.register("UnitTests:tryme", function (what) { return what * 2; }, true);
assertEqual("function (what) { return what * 2; }", aqlfunctions.toArray("UnitTests")[0].code);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test registered code
////////////////////////////////////////////////////////////////////////////////
testRegisterCode2 : function () {
unregister("UnitTests:tryme");
aqlfunctions.register("UnitTests:tryme", "function (what) { return what * 2; }", true);
assertEqual("function (what) { return what * 2; }", aqlfunctions.toArray("UnitTests")[0].code);
},
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief register a function /// @brief register a function
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////