Skip to content

Commit

Permalink
Added Spec Tests for 2 Operations
Browse files Browse the repository at this point in the history
Added to spec tests to very that the operations...

For testing batch delete node :
 - 2 node created one by one
 - Nodes deleted in batch
 - Get nodes results should be nil

For testing batch remove node :
 - Create two nodes with indicies one by one
 - In batch remove the node from the indidicies
 - Search for exact nodes should be nil
  • Loading branch information
samirahmed committed Jun 20, 2012
1 parent a079b5a commit a2bdf97
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
6 changes: 1 addition & 5 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,7 @@ def get_batch(args)
{:method => "POST", :to => @cypher_path, :body => {:query => args[1]}}
end
when :remove_node_from_index
case args.size
when 5 then {:method => "DELETE", :to => "/index/node/#{args[1]}/#{args[2]}/#{args[3]}/#{get_id(args[4])}" }
when 4 then {:method => "DELETE", :to => "/index/node/#{args[1]}/#{args[2]}/#{get_id(args[3])}" }
when 3 then {:method => "DELETE", :to => "/index/node/#{args[1]}/#{get_id(args[2])}" }
end
{:method => "DELETE", :to => "/index/node/#{args[1]}/#{args[2]}/#{args[3]}/#{get_id(args[4])}" }
when :delete_node
{:method => "DELETE", :to => "/node/#{get_id(args[1])}"}
else
Expand Down
28 changes: 27 additions & 1 deletion spec/integration/rest_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,32 @@
batch_result.first["body"]["data"][0][0]["self"].split('/').last.should == id
end

it "can delete a node in batch" do

node1 = @neo.create_node
node2 = @neo.create_node
id1 = node1['self'].split('/').last
id2 = node2['self'].split('/').last
batch_result = @neo.batch [:delete_node, id1 ], [:delete_node, id2]
@neo.get_node(node1).should be_nil
@neo.get_node(node2).should be_nil

end

it "can remove a node from an index in batch " do
index = generate_text(6)
key = generate_text(6)
value1 = generate_text
value2 = generate_text

node1 = @neo.create_unique_node( index , key , value1 , { "name" => "Max" } )
node2 = @neo.create_unique_node( index , key , value2 , { "name" => "Neo" })

batch_result = @neo.batch [:remove_node_from_index, index, key, value1, node1 ], [:remove_node_from_index, index, key, value2, node2 ]

@neo.get_node_index(index, key, value1).should be_nil
@neo.get_node_index(index, key, value2).should be_nil
end

end

Expand Down Expand Up @@ -365,4 +391,4 @@

end

end
end

0 comments on commit a2bdf97

Please sign in to comment.