From 3da00d24ea1a361186d339e4b72585fe13b76a6f Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Mon, 21 Mar 2016 18:25:48 +0100 Subject: [PATCH] test fixes --- API-Changes-3.0.md | 3 +++ UnitTests/HttpInterface/api-edges-spec.rb | 18 +++++++++--------- arangod/RestHandler/RestBatchHandler.cpp | 12 ++++++------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/API-Changes-3.0.md b/API-Changes-3.0.md index cecd0b29e1..082bc58171 100644 --- a/API-Changes-3.0.md +++ b/API-Changes-3.0.md @@ -19,6 +19,9 @@ Overview 5. Query-parameters "policy" and "rev" withdrawn in replace()/update() 6. /_api/edge withdrawn + use /_api/document instead + Attributes `_from` and `_to` for edges must be passed inside the + document body and not as URL parameters `from` and `to` 7. .BY_EXAMPLE_HASH , .BY_EXAMPLE_SKIPLIST, .BY_CONDITION_SKIPLIST deleted. diff --git a/UnitTests/HttpInterface/api-edges-spec.rb b/UnitTests/HttpInterface/api-edges-spec.rb index 80e2e3e761..260127ed7c 100644 --- a/UnitTests/HttpInterface/api-edges-spec.rb +++ b/UnitTests/HttpInterface/api-edges-spec.rb @@ -110,8 +110,8 @@ describe ArangoDB do id2 = doc.parsed_response['_id'] # create edge - cmd = "/_api/edge?collection=#{@ce}&from=#{id1}&to=#{id2}" - body = "{}" + cmd = "/_api/document?collection=#{@ce}" + body = "{\"_from\":\"#{id1}\",\"_to\":\"#{id2}\"}" doc = ArangoDB.log_post("#{prefix}-create-edge", cmd, :body => body) doc.code.should eq(201) @@ -123,7 +123,7 @@ describe ArangoDB do id3 = doc.parsed_response['_id'] # check edge - cmd = "/_api/edge/#{id3}" + cmd = "/_api/document/#{id3}" doc = ArangoDB.log_get("#{prefix}-read-edge", cmd) doc.code.should eq(200) @@ -133,8 +133,8 @@ describe ArangoDB do doc.headers['content-type'].should eq("application/json; charset=utf-8") # create another edge - cmd = "/_api/edge?collection=#{@ce}&from=#{id1}&to=#{id2}" - body = "{ \"e\" : 1 }" + cmd = "/_api/document?collection=#{@ce}" + body = "{ \"e\" : 1, \"_from\" : \"#{id1}\", \"_to\": \"#{id2}\" }" doc = ArangoDB.log_post("#{prefix}-create-edge", cmd, :body => body) doc.code.should eq(201) @@ -144,7 +144,7 @@ describe ArangoDB do id4 = doc.parsed_response['_id'] # check edge - cmd = "/_api/edge/#{id4}" + cmd = "/_api/document/#{id4}" doc = ArangoDB.log_get("#{prefix}-read-edge", cmd) doc.code.should eq(200) @@ -161,8 +161,8 @@ describe ArangoDB do doc.headers['content-type'].should eq("application/json; charset=utf-8") # create third edge - cmd = "/_api/edge?collection=#{@ce}&from=#{id2}&to=#{id1}" - body = "{ \"e\" : 2 }" + cmd = "/_api/document?collection=#{@ce}" + body = "{ \"e\" : 2, \"_from\" : \"#{id2}\", \"_to\" : \"#{id1}\" }" doc = ArangoDB.log_post("#{prefix}-create-edge", cmd, :body => body) doc.code.should eq(201) @@ -174,7 +174,7 @@ describe ArangoDB do id5 = doc.parsed_response['_id'] # check edge - cmd = "/_api/edge/#{id5}" + cmd = "/_api/document/#{id5}" doc = ArangoDB.log_get("#{prefix}-read-edge", cmd) doc.code.should eq(200) diff --git a/arangod/RestHandler/RestBatchHandler.cpp b/arangod/RestHandler/RestBatchHandler.cpp index 83b1b8f617..865e86670a 100644 --- a/arangod/RestHandler/RestBatchHandler.cpp +++ b/arangod/RestHandler/RestBatchHandler.cpp @@ -99,12 +99,12 @@ HttpHandler::status_t RestBatchHandler::execute() { size_t const partLength = helper.foundLength; char const* headerStart = partStart; - char* bodyStart = nullptr; + char const* bodyStart = nullptr; size_t headerLength = 0; size_t bodyLength = 0; // assume Windows linebreak \r\n\r\n as delimiter - char* p = strstr((char*)headerStart, "\r\n\r\n"); + char const* p = strstr(headerStart, "\r\n\r\n"); if (p != nullptr && p + 4 <= partEnd) { headerLength = p - partStart; @@ -112,7 +112,7 @@ HttpHandler::status_t RestBatchHandler::execute() { bodyLength = partEnd - bodyStart; } else { // test Unix linebreak - p = strstr((char*)headerStart, "\n\n"); + p = strstr(headerStart, "\n\n"); if (p != nullptr && p + 2 <= partEnd) { headerLength = p - partStart; @@ -149,14 +149,14 @@ HttpHandler::status_t RestBatchHandler::execute() { request->setBody(bodyStart, bodyLength); } - if (authorization.size()) { + if (!authorization.empty()) { // inject Authorization header of multipart message into part message request->setHeader("authorization", 13, authorization.c_str()); } HttpHandler* handler = _server->createHandler(request); - if (!handler) { + if (handler == nullptr) { delete request; generateError(HttpResponse::BAD, TRI_ERROR_INTERNAL, @@ -186,7 +186,7 @@ HttpHandler::status_t RestBatchHandler::execute() { return status_t(HttpHandler::HANDLER_FAILED); } - const HttpResponse::HttpResponseCode code = partResponse->responseCode(); + HttpResponse::HttpResponseCode const code = partResponse->responseCode(); // count everything above 400 as error if (code >= 400) {