mirror of https://gitee.com/bigwinds/arangodb
Adjust tests for 3.0.
This commit is contained in:
parent
bffd86b035
commit
fbcb4458eb
|
@ -14,18 +14,6 @@ describe ArangoDB do
|
|||
################################################################################
|
||||
|
||||
context "error handling:" do
|
||||
it "returns an error if url contains a suffix" do
|
||||
cmd = "/_api/document/123456"
|
||||
body = "{}"
|
||||
doc = ArangoDB.log_post("#{prefix}-superfluous-suffix", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(400)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['errorNum'].should eq(601)
|
||||
doc.parsed_response['code'].should eq(400)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
end
|
||||
|
||||
it "returns an error if collection idenifier is missing" do
|
||||
cmd = "/_api/document"
|
||||
body = "{}"
|
||||
|
@ -139,11 +127,10 @@ describe ArangoDB do
|
|||
it "creating a new document" do
|
||||
cmd = "/_api/document?collection=#{@cn}"
|
||||
body = "{ \"Hallo\" : \"World\" }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body, :headers => { "x-arango-version" => "1.3" })
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body, :headers => {})
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -162,7 +149,7 @@ describe ArangoDB do
|
|||
match[1].should eq("#{@cn}")
|
||||
|
||||
etag.should eq("\"#{rev}\"")
|
||||
location.should eq("/_api/document/#{did}")
|
||||
location.should eq("/_db/_system/_api/document/#{did}")
|
||||
|
||||
ArangoDB.delete(location)
|
||||
|
||||
|
@ -176,7 +163,6 @@ describe ArangoDB do
|
|||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -205,11 +191,10 @@ describe ArangoDB do
|
|||
it "creating a new document complex body" do
|
||||
cmd = "/_api/document?collection=#{@cn}"
|
||||
body = "{ \"Hallo\" : \"Wo\\\"rld\" }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body, :headers => { "x-arango-version" => "1.3" })
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body, :headers => {})
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -228,7 +213,7 @@ describe ArangoDB do
|
|||
match[1].should eq("#{@cn}")
|
||||
|
||||
etag.should eq("\"#{rev}\"")
|
||||
location.should eq("/_api/document/#{did}")
|
||||
location.should eq("/_db/_system/_api/document/#{did}")
|
||||
|
||||
cmd = "/_api/document/#{did}"
|
||||
doc = ArangoDB.log_get("#{prefix}-complex", cmd)
|
||||
|
@ -249,7 +234,6 @@ describe ArangoDB do
|
|||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -285,11 +269,10 @@ describe ArangoDB do
|
|||
it "creating a new umlaut document" do
|
||||
cmd = "/_api/document?collection=#{@cn}"
|
||||
body = "{ \"Hallo\" : \"öäüÖÄÜßあ寿司\" }"
|
||||
doc = ArangoDB.log_post("#{prefix}-umlaut", cmd, :body => body, :headers => { "x-arango-version" => "1.3" })
|
||||
doc = ArangoDB.log_post("#{prefix}-umlaut", cmd, :body => body, :headers => {})
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -308,7 +291,7 @@ describe ArangoDB do
|
|||
match[1].should eq("#{@cn}")
|
||||
|
||||
etag.should eq("\"#{rev}\"")
|
||||
location.should eq("/_api/document/#{did}")
|
||||
location.should eq("/_db/_system/_api/document/#{did}")
|
||||
|
||||
cmd = "/_api/document/#{did}"
|
||||
doc = ArangoDB.log_get("#{prefix}-umlaut", cmd)
|
||||
|
@ -319,7 +302,7 @@ describe ArangoDB do
|
|||
newBody = doc.body()
|
||||
newBody = newBody.sub!(/^.*"Hallo":"([^"]*)".*$/, '\1')
|
||||
|
||||
newBody.should eq("\\u00F6\\u00E4\\u00FC\\u00D6\\u00C4\\u00DC\\u00DF\\u3042\\u5BFF\\u53F8")
|
||||
newBody.should eq("öäüÖÄÜßあ寿司")
|
||||
|
||||
doc.parsed_response['Hallo'].should eq('öäüÖÄÜßあ寿司')
|
||||
|
||||
|
@ -335,7 +318,6 @@ describe ArangoDB do
|
|||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -365,7 +347,7 @@ describe ArangoDB do
|
|||
newBody = doc.body()
|
||||
newBody = newBody.sub!(/^.*"Hallo":"([^"]*)".*$/, '\1')
|
||||
|
||||
newBody.should eq("\\u00F6\\u00E4\\u00FC\\u00D6\\u00C4\\u00DC\\u00DF\\u3042\\u5BFF\\u53F8")
|
||||
newBody.should eq("öäüÖÄÜßあ寿司")
|
||||
|
||||
doc.parsed_response['Hallo'].should eq('öäüÖÄÜßあ寿司')
|
||||
|
||||
|
@ -376,58 +358,11 @@ describe ArangoDB do
|
|||
|
||||
it "creating a new not normalized umlaut document" do
|
||||
cmd = "/_api/document?collection=#{@cn}"
|
||||
body = "{ \"Hallo\" : \"Gru\\u0308\\u00DF Gott.\" }"
|
||||
doc = ArangoDB.log_post("#{prefix}-umlaut", cmd, :body => body, :headers => { "x-arango-version" => "1.3" })
|
||||
body = "{ \"Hallo\" : \"Grüß Gott.\" }"
|
||||
doc = ArangoDB.log_post("#{prefix}-umlaut", cmd, :body => body, :headers => {})
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
||||
location = doc.headers['location']
|
||||
location.should be_kind_of(String)
|
||||
|
||||
rev = doc.parsed_response['_rev']
|
||||
rev.should be_kind_of(String)
|
||||
|
||||
did = doc.parsed_response['_id']
|
||||
did.should be_kind_of(String)
|
||||
|
||||
match = didRegex.match(did)
|
||||
|
||||
match[1].should eq("#{@cn}")
|
||||
|
||||
etag.should eq("\"#{rev}\"")
|
||||
location.should eq("/_api/document/#{did}")
|
||||
|
||||
cmd = "/_api/document/#{did}"
|
||||
doc = ArangoDB.log_get("#{prefix}-umlaut", cmd)
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
|
||||
newBody = doc.body()
|
||||
newBody = newBody.sub!(/^.*"Hallo":"([^"]*)".*$/, '\1')
|
||||
|
||||
newBody.should eq("Gr\\u00FC\\u00DF Gott.")
|
||||
|
||||
doc.parsed_response['Hallo'].should eq('Grüß Gott.')
|
||||
|
||||
ArangoDB.delete(location)
|
||||
|
||||
ArangoDB.size_collection(@cn).should eq(0)
|
||||
end
|
||||
|
||||
it "creating a new not normalized umlaut document, setting compatibility header" do
|
||||
cmd = "/_api/document?collection=#{@cn}"
|
||||
body = "{ \"Hallo\" : \"Gru\\u0308\\u00DF Gott.\" }"
|
||||
doc = ArangoDB.log_post("#{prefix}-umlaut", cmd, :body => body, :headers => { "x-arango-version" => "1.4" })
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -457,7 +392,52 @@ describe ArangoDB do
|
|||
newBody = doc.body()
|
||||
newBody = newBody.sub!(/^.*"Hallo":"([^"]*)".*$/, '\1')
|
||||
|
||||
newBody.should eq("Gr\\u00FC\\u00DF Gott.")
|
||||
newBody.should eq("Grüß Gott.")
|
||||
|
||||
doc.parsed_response['Hallo'].should eq('Grüß Gott.')
|
||||
|
||||
ArangoDB.delete(location)
|
||||
|
||||
ArangoDB.size_collection(@cn).should eq(0)
|
||||
end
|
||||
|
||||
it "creating a new not normalized umlaut document, setting compatibility header" do
|
||||
cmd = "/_api/document?collection=#{@cn}"
|
||||
body = "{ \"Hallo\" : \"Grüß Gott.\" }"
|
||||
doc = ArangoDB.log_post("#{prefix}-umlaut", cmd, :body => body, :headers => { "x-arango-version" => "1.4" })
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
||||
location = doc.headers['location']
|
||||
location.should be_kind_of(String)
|
||||
|
||||
rev = doc.parsed_response['_rev']
|
||||
rev.should be_kind_of(String)
|
||||
|
||||
did = doc.parsed_response['_id']
|
||||
did.should be_kind_of(String)
|
||||
|
||||
match = didRegex.match(did)
|
||||
|
||||
match[1].should eq("#{@cn}")
|
||||
|
||||
etag.should eq("\"#{rev}\"")
|
||||
location.should eq("/_db/_system/_api/document/#{did}")
|
||||
|
||||
cmd = "/_api/document/#{did}"
|
||||
doc = ArangoDB.log_get("#{prefix}-umlaut", cmd)
|
||||
|
||||
doc.code.should eq(200)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
|
||||
newBody = doc.body()
|
||||
newBody = newBody.sub!(/^.*"Hallo":"([^"]*)".*$/, '\1')
|
||||
|
||||
newBody.should eq("Grüß Gott.")
|
||||
|
||||
doc.parsed_response['Hallo'].should eq('Grüß Gott.')
|
||||
|
||||
|
@ -473,11 +453,10 @@ describe ArangoDB do
|
|||
|
||||
cmd = "/_api/document?collection=#{@cn}"
|
||||
body = "{ \"some stuff\" : \"goes here\", \"_key\" : \"#{@key}\" }"
|
||||
doc = ArangoDB.log_post("#{prefix}-existing-id", cmd, :body => body, :headers => { "x-arango-version" => "1.3" })
|
||||
doc = ArangoDB.log_post("#{prefix}-existing-id", cmd, :body => body, :headers => {})
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -496,7 +475,7 @@ describe ArangoDB do
|
|||
|
||||
match[1].should eq("#{@cn}")
|
||||
|
||||
location.should eq("/_api/document/#{did}")
|
||||
location.should eq("/_db/_system/_api/document/#{did}")
|
||||
|
||||
ArangoDB.delete("/_api/document/#{@cn}/#{@key}")
|
||||
end
|
||||
|
@ -512,7 +491,6 @@ describe ArangoDB do
|
|||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -575,11 +553,10 @@ describe ArangoDB do
|
|||
it "creating a new document" do
|
||||
cmd = "/_api/document?collection=#{@cn}"
|
||||
body = "{ \"Hallo\" : \"World\" }"
|
||||
doc = ArangoDB.log_post("#{prefix}-accept", cmd, :body => body, :headers => { "x-arango-version" => "1.3" })
|
||||
doc = ArangoDB.log_post("#{prefix}-accept", cmd, :body => body, :headers => {})
|
||||
|
||||
doc.code.should eq(202)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -598,7 +575,7 @@ describe ArangoDB do
|
|||
match[1].should eq("#{@cn}")
|
||||
|
||||
etag.should eq("\"#{rev}\"")
|
||||
location.should eq("/_api/document/#{did}")
|
||||
location.should eq("/_db/_system/_api/document/#{did}")
|
||||
|
||||
ArangoDB.delete(location)
|
||||
|
||||
|
@ -612,7 +589,6 @@ describe ArangoDB do
|
|||
|
||||
doc.code.should eq(202)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -641,11 +617,10 @@ describe ArangoDB do
|
|||
it "creating a new document, waitForSync URL param = false" do
|
||||
cmd = "/_api/document?collection=#{@cn}&waitForSync=false"
|
||||
body = "{ \"Hallo\" : \"World\" }"
|
||||
doc = ArangoDB.log_post("#{prefix}-accept-sync-false", cmd, :body => body, :headers => { "x-arango-version" => "1.3" })
|
||||
doc = ArangoDB.log_post("#{prefix}-accept-sync-false", cmd, :body => body, :headers => {})
|
||||
|
||||
doc.code.should eq(202)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -664,7 +639,7 @@ describe ArangoDB do
|
|||
match[1].should eq("#{@cn}")
|
||||
|
||||
etag.should eq("\"#{rev}\"")
|
||||
location.should eq("/_api/document/#{did}")
|
||||
location.should eq("/_db/_system/_api/document/#{did}")
|
||||
|
||||
ArangoDB.delete(location)
|
||||
|
||||
|
@ -678,7 +653,6 @@ describe ArangoDB do
|
|||
|
||||
doc.code.should eq(202)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -707,11 +681,10 @@ describe ArangoDB do
|
|||
it "creating a new document, waitForSync URL param = true" do
|
||||
cmd = "/_api/document?collection=#{@cn}&waitForSync=true"
|
||||
body = "{ \"Hallo\" : \"World\" }"
|
||||
doc = ArangoDB.log_post("#{prefix}-accept-sync-true", cmd, :body => body, :headers => { "x-arango-version" => "1.3" })
|
||||
doc = ArangoDB.log_post("#{prefix}-accept-sync-true", cmd, :body => body, :headers => {})
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -730,7 +703,7 @@ describe ArangoDB do
|
|||
match[1].should eq("#{@cn}")
|
||||
|
||||
etag.should eq("\"#{rev}\"")
|
||||
location.should eq("/_api/document/#{did}")
|
||||
location.should eq("/_db/_system/_api/document/#{did}")
|
||||
|
||||
ArangoDB.delete(location)
|
||||
|
||||
|
@ -744,7 +717,6 @@ describe ArangoDB do
|
|||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -788,11 +760,10 @@ describe ArangoDB do
|
|||
it "creating a new document" do
|
||||
cmd = "/_api/document?collection=#{@cn}"
|
||||
body = "{ \"Hallo\" : \"World\" }"
|
||||
doc = ArangoDB.log_post("#{prefix}-named-collection", cmd, :body => body, :headers => { "x-arango-version" => "1.3" })
|
||||
doc = ArangoDB.log_post("#{prefix}-named-collection", cmd, :body => body, :headers => {})
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
@ -811,7 +782,7 @@ describe ArangoDB do
|
|||
match[1].should eq("#{@cn}")
|
||||
|
||||
etag.should eq("\"#{rev}\"")
|
||||
location.should eq("/_api/document/#{did}")
|
||||
location.should eq("/_db/_system/_api/document/#{did}")
|
||||
|
||||
ArangoDB.delete(location)
|
||||
|
||||
|
@ -825,7 +796,6 @@ describe ArangoDB do
|
|||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
|
||||
etag = doc.headers['etag']
|
||||
etag.should be_kind_of(String)
|
||||
|
|
|
@ -236,7 +236,6 @@ describe ArangoDB do
|
|||
doc = ArangoDB.log_post("#{prefix}-valid", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['_key'].should eq(key)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
end
|
||||
|
@ -264,7 +263,6 @@ describe ArangoDB do
|
|||
doc = ArangoDB.log_post("#{prefix}-valid", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['_key'].should eq(key)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
|
||||
|
|
Loading…
Reference in New Issue