eval raises OperationFailure on error. test for group that already passes
This commit is contained in:
parent
c49c208bff
commit
c6969fcb4d
@ -421,7 +421,7 @@ module XGen
|
|||||||
oh[:args] = args
|
oh[:args] = args
|
||||||
doc = db_command(oh)
|
doc = db_command(oh)
|
||||||
return doc['retval'] if ok?(doc)
|
return doc['retval'] if ok?(doc)
|
||||||
raise "Error with eval command: #{doc.inspect}"
|
raise OperationFailure, "eval failed: #{doc['errmsg']}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Rename collection +from+ to +to+. Meant to be called by
|
# Rename collection +from+ to +to+. Meant to be called by
|
||||||
|
@ -554,7 +554,7 @@ class DBAPITest < Test::Unit::TestCase
|
|||||||
assert_equal 2, @@db.eval(Code.new("return i;", {"i" => 2}))
|
assert_equal 2, @@db.eval(Code.new("return i;", {"i" => 2}))
|
||||||
assert_equal 5, @@db.eval(Code.new("i + 3;", {"i" => 2}))
|
assert_equal 5, @@db.eval(Code.new("i + 3;", {"i" => 2}))
|
||||||
|
|
||||||
assert_raise RuntimeError do
|
assert_raise OperationFailure do
|
||||||
@@db.eval("5 ++ 5;")
|
@@db.eval("5 ++ 5;")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -613,6 +613,10 @@ class DBAPITest < Test::Unit::TestCase
|
|||||||
{"a" => nil, "count" => 1},
|
{"a" => nil, "count" => 1},
|
||||||
{"a" => 1, "count" => 1}]
|
{"a" => 1, "count" => 1}]
|
||||||
assert_equal expected, test.group(["a"], {}, {"count" => 0}, "function (obj, prev) { prev.count++; }")
|
assert_equal expected, test.group(["a"], {}, {"count" => 0}, "function (obj, prev) { prev.count++; }")
|
||||||
|
|
||||||
|
assert_raise OperationFailure do
|
||||||
|
test.group([], {}, {}, "5 ++ 5")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_deref
|
def test_deref
|
||||||
|
Loading…
Reference in New Issue
Block a user