You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by jc...@apache.org on 2009/06/14 06:18:53 UTC
svn commit: r784506 - in /couchdb/branches/list-iterator:
share/server/render.js test/query_server_spec.rb
Author: jchris
Date: Sun Jun 14 04:18:52 2009
New Revision: 784506
URL: http://svn.apache.org/viewvc?rev=784506&view=rev
Log:
Warn users of old style list functions when they are run against the new API.
Modified:
couchdb/branches/list-iterator/share/server/render.js
couchdb/branches/list-iterator/test/query_server_spec.rb
Modified: couchdb/branches/list-iterator/share/server/render.js
URL: http://svn.apache.org/viewvc/couchdb/branches/list-iterator/share/server/render.js?rev=784506&r1=784505&r2=784506&view=diff
==============================================================================
--- couchdb/branches/list-iterator/share/server/render.js (original)
+++ couchdb/branches/list-iterator/share/server/render.js Sun Jun 14 04:18:52 2009
@@ -287,6 +287,9 @@
gotRow = false;
lastRow = false;
respTail = "";
+ if (renderFun.arity > 2) {
+ throw("the list API has changed for CouchDB 0.10, please upgrade your code");
+ }
var resp = renderFun.apply(null, args);
if (!gotRow) {
getRow();
Modified: couchdb/branches/list-iterator/test/query_server_spec.rb
URL: http://svn.apache.org/viewvc/couchdb/branches/list-iterator/test/query_server_spec.rb?rev=784506&r1=784505&r2=784506&view=diff
==============================================================================
--- couchdb/branches/list-iterator/test/query_server_spec.rb (original)
+++ couchdb/branches/list-iterator/test/query_server_spec.rb Sun Jun 14 04:18:52 2009
@@ -251,7 +251,7 @@
end
it "should should list em" do
@qs.rrun(["list", {"foo"=>"bar"}, {"q" => "ok"}])
- @qs.jsgets.should == ["start", ["first chunk", "ok"], {}]
+ @qs.jsgets.should == ["start", ["first chunk", "ok"], {"headers"=>{}}]
@qs.rrun(["list_row", {"key"=>"baz"}])
@qs.get_chunks.should == ["baz"]
@qs.rrun(["list_row", {"key"=>"bam"}])
@@ -261,7 +261,7 @@
end
it "should work with zero rows" do
@qs.rrun(["list", {"foo"=>"bar"}, {"q" => "ok"}])
- @qs.jsgets.should == ["start", ["first chunk", "ok"], {}]
+ @qs.jsgets.should == ["start", ["first chunk", "ok"], {"headers"=>{}}]
@qs.rrun(["list_end"])
@qs.jsgets.should == ["end", ["tail"]]
end
@@ -286,7 +286,7 @@
end
it "should should buffer em" do
@qs.rrun(["list", {"foo"=>"bar"}, {"q" => "ok"}])
- @qs.jsgets.should == ["start", ["bacon"], {}]
+ @qs.jsgets.should == ["start", ["bacon"], {"headers"=>{}}]
@qs.rrun(["list_row", {"key"=>"baz"}])
@qs.get_chunks.should == ["baz", "eggs"]
@qs.rrun(["list_row", {"key"=>"bam"}])
@@ -313,7 +313,7 @@
@qs.add_fun(@fun).should == true
end
it "should run normal" do
- @qs.run(["list", {"foo"=>"bar"}, {"q" => "ok"}]).should == ["start", ["first chunk", "ok"], {}]
+ @qs.run(["list", {"foo"=>"bar"}, {"q" => "ok"}]).should == ["start", ["first chunk", "ok"], {"headers"=>{}}]
@qs.run(["list_row", {"key"=>"baz"}]).should == ["chunks", ["baz"]]
@qs.run(["list_row", {"key"=>"bam"}]).should == ["chunks", ["bam"]]
@qs.run(["list_row", {"key"=>"foom"}]).should == ["chunks", ["foom"]]
@@ -344,7 +344,7 @@
end
it "should end early" do
@qs.run(["list", {"foo"=>"bar"}, {"q" => "ok"}]).
- should == ["start", ["first chunk", "ok"], {}]
+ should == ["start", ["first chunk", "ok"], {"headers"=>{}}]
@qs.run(["list_row", {"key"=>"baz"}]).
should == ["chunks", ["baz"]]
@@ -360,6 +360,17 @@
end
end
+def should_have_exited qs
+ begin
+ qs.run(["reset"])
+ "raise before this".should == true
+ rescue RuntimeError => e
+ e.message.should == "no response"
+ rescue Errno::EPIPE
+ true.should == true
+ end
+end
+
describe "query server that exits" do
before(:each) do
@qs = QueryServerRunner.run
@@ -368,6 +379,23 @@
@qs.close
end
+ describe "old style list" do
+ before(:each) do
+ @fun = <<-JS
+ function(head, req, foo, bar) {
+ return "stuff";
+ }
+ JS
+ @qs.reset!
+ @qs.add_fun(@fun).should == true
+ end
+ it "should get a warning" do
+ resp = @qs.run(["list", {"foo"=>"bar"}, {"q" => "ok"}])
+ resp["error"].should == "render_error"
+ resp["reason"].should include("the list API has changed")
+ end
+ end
+
describe "only goes to 2 list" do
before(:each) do
@fun = <<-JS
@@ -387,20 +415,13 @@
@qs.add_fun(@fun).should == true
end
it "should exit if erlang sends too many rows" do
- @qs.run(["list", {"foo"=>"bar"}, {"q" => "ok"}]).should == ["start", ["bacon"], {}]
+ @qs.run(["list", {"foo"=>"bar"}, {"q" => "ok"}]).should == ["start", ["bacon"], {"headers"=>{}}]
@qs.run(["list_row", {"key"=>"baz"}]).should == ["chunks", ["baz"]]
@qs.run(["list_row", {"key"=>"foom"}]).should == ["chunks", ["foom"]]
@qs.run(["list_row", {"key"=>"fooz"}]).should == ["end", ["fooz", "early"]]
@qs.rrun(["list_row", {"key"=>"foox"}])
@qs.jsgets["error"].should == "query_server_error"
- begin
- @qs.run(["reset"])
- "raise before this".should == true
- rescue RuntimeError => e
- e.message.should == "no response"
- rescue Errno::EPIPE
- true.should == true
- end
+ should_have_exited @qs
end
end
@@ -422,16 +443,9 @@
end
it "should exit if it gets a non-row in the middle" do
@qs.rrun(["list", {"foo"=>"bar"}, {"q" => "ok"}])
- @qs.jsgets.should == ["start", ["first chunk", "ok"], {}]
+ @qs.jsgets.should == ["start", ["first chunk", "ok"], {"headers"=>{}}]
@qs.run(["reset"])["error"].should == "query_server_error"
- begin
- @qs.run(["reset"])
- "raise before this".should == true
- rescue RuntimeError => e
- e.message.should == "no response"
- rescue Errno::EPIPE
- true.should == true
- end
+ should_have_exited @qs
end
end
end