couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r755105 - in /couchdb/trunk/share: Makefile.am www/script/couch_tests.js www/script/test/view_offsets.js
Date Tue, 17 Mar 2009 03:47:38 GMT
Author: davisp
Date: Tue Mar 17 03:47:37 2009
New Revision: 755105

URL: http://svn.apache.org/viewvc?rev=755105&view=rev
Log:
Closes COUCHDB-135 View offset regression after 0.8.1

This test shows that Damien's changes to couch_btree.erl have alleviated the
offset regersion reported by Paul Carey.


Added:
    couchdb/trunk/share/www/script/test/view_offsets.js
Modified:
    couchdb/trunk/share/Makefile.am
    couchdb/trunk/share/www/script/couch_tests.js

Modified: couchdb/trunk/share/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/Makefile.am?rev=755105&r1=755104&r2=755105&view=diff
==============================================================================
--- couchdb/trunk/share/Makefile.am (original)
+++ couchdb/trunk/share/Makefile.am Tue Mar 17 03:47:37 2009
@@ -100,6 +100,7 @@
     www/script/test/view_multi_key_all_docs.js \
     www/script/test/view_multi_key_design.js \
     www/script/test/view_multi_key_temp.js \
+	www/script/test/view_offsets.js \
     www/script/test/view_pagination.js \
     www/script/test/view_sandboxing.js \
     www/script/test/view_xml.js \

Modified: couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch_tests.js?rev=755105&r1=755104&r2=755105&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch_tests.js [utf-8] Tue Mar 17 03:47:37 2009
@@ -55,6 +55,7 @@
 loadTest("view_multi_key_all_docs.js");
 loadTest("view_multi_key_design.js");
 loadTest("view_multi_key_temp.js");
+loadTest("view_offsets.js");
 loadTest("view_pagination.js");
 loadTest("view_sandboxing.js");
 loadTest("view_xml.js");

Added: couchdb/trunk/share/www/script/test/view_offsets.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/view_offsets.js?rev=755105&view=auto
==============================================================================
--- couchdb/trunk/share/www/script/test/view_offsets.js (added)
+++ couchdb/trunk/share/www/script/test/view_offsets.js Tue Mar 17 03:47:37 2009
@@ -0,0 +1,101 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License.  You may obtain a copy
+// of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+couchTests.view_offsets = function(debug) {
+  if (debug) debugger;      
+
+  var db = new CouchDB("test_suite_db");
+  db.deleteDb();
+  db.createDb();
+  
+  var designDoc = {
+    _id : "_design/test",
+    views : {
+      offset : {
+        map : "function(doc) { emit([doc.letter, doc.number], doc); }",
+      }
+    }
+  };
+  T(db.save(designDoc).ok);
+  
+  var docs = [
+    {_id : "a1", letter : "a", number : 1, foo: "bar"},
+    {_id : "a2", letter : "a", number : 2, foo: "bar"},
+    {_id : "a3", letter : "a", number : 3, foo: "bar"},
+    {_id : "b1", letter : "b", number : 1, foo: "bar"},
+    {_id : "b2", letter : "b", number : 2, foo: "bar"},
+    {_id : "b3", letter : "b", number : 3, foo: "bar"},
+    {_id : "b4", letter : "b", number : 4, foo: "bar"},
+    {_id : "b5", letter : "b", number : 5, foo: "bar"},
+    {_id : "c1", letter : "c", number : 1, foo: "bar"},
+    {_id : "c2", letter : "c", number : 2, foo: "bar"},
+  ];
+  db.bulkSave(docs);
+
+  var check = function(startkey, offset) {
+    var opts = {startkey: startkey, descending: true, reduce: false};
+    T(db.view("test/offset", opts).offset == offset);
+  };
+
+  [
+      [["c", 2], 0],
+      [["c", 1], 1],
+      [["b", 5], 2],
+      [["b", 4], 3],
+      [["b", 3], 4],
+      [["b", 2], 5],
+      [["b", 1], 6],
+      [["a", 3], 7],
+      [["a", 2], 8],
+      [["a", 1], 9]
+  ].forEach(function(row){ check(row[0], row[1]);});
+
+  var runTest = function () {
+    var db = new CouchDB("test_suite_db");
+    db.deleteDb();
+    db.createDb();
+
+    var designDoc = {
+      _id : "_design/test",
+      views : {
+        offset : {
+          map : "function(doc) { emit([doc.letter, doc.number], doc);}",
+        }
+      }
+    };
+    T(db.save(designDoc).ok);
+
+    var docs = [
+      {_id : "a1", letter : "a", number : 1, foo : "bar"},
+      {_id : "a2", letter : "a", number : 2, foo : "bar"},
+      {_id : "a3", letter : "a", number : 3, foo : "bar"},
+      {_id : "b1", letter : "b", number : 1, foo : "bar"},
+      {_id : "b2", letter : "b", number : 2, foo : "bar"},
+      {_id : "b3", letter : "b", number : 3, foo : "bar"},
+      {_id : "b4", letter : "b", number : 4, foo : "bar"},
+      {_id : "b5", letter : "b", number : 5, foo : "bar"},
+      {_id : "c1", letter : "c", number : 1, foo : "bar"},
+      {_id : "c2", letter : "c", number : 2, foo : "bar"}
+    ];
+    db.bulkSave(docs);
+
+    var res = db.view("test/offset", { 
+      startkey: ["b",4], startkey_docid: "b4", endkey: ["b"], 
+      limit: 2, descending: true, skip: 1, reduce: false
+    })
+
+    return res.offset == 4;
+  };
+
+  for(var i = 0; i < 15; i++) T(runTest());
+}
+



Mime
View raw message