diff options
author | John Christopher Anderson <jchris@apache.org> | 2010-04-22 15:08:08 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2010-04-22 15:08:08 +0000 |
commit | 3143d4eba8b40b33c3dbe5897d6fdb7ec7377f71 (patch) | |
tree | 976dba9dbe5f555f60eb77cf0f52e63242232608 /share/www | |
parent | 5c758e7f2ca47b1285d08f170b5105b618fb956e (diff) |
fix erlang filter funs and normalize filter fun api. thanks fdmanana. closes COUCHDB-740
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@936889 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r-- | share/www/script/test/changes.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/share/www/script/test/changes.js b/share/www/script/test/changes.js index 1240712f..72ec0279 100644 --- a/share/www/script/test/changes.js +++ b/share/www/script/test/changes.js @@ -347,5 +347,44 @@ couchTests.changes = function(debug) { req = CouchDB.request("GET", "/test_suite_db/_changes?filter=changes_filter/conflicted"); resp = JSON.parse(req.responseText); T(resp.results.length == 1); + + // test with erlang filter function + run_on_modified_server([{ + section: "native_query_servers", + key: "erlang", + value: "{couch_native_process, start_link, []}" + }], function() { + var erl_ddoc = { + _id: "_design/erlang", + language: "erlang", + filters: { + foo: + 'fun({Doc}, Req) -> ' + + ' Value = proplists:get_value(<<"value">>, Doc),' + + ' (Value rem 2) =:= 0' + + 'end.' + } + }; + + db.deleteDb(); + db.createDb(); + T(db.save(erl_ddoc).ok); + + var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=erlang/foo"); + var resp = JSON.parse(req.responseText); + T(resp.results.length === 0); + + T(db.save({_id: "doc1", value : 1}).ok); + T(db.save({_id: "doc2", value : 2}).ok); + T(db.save({_id: "doc3", value : 3}).ok); + T(db.save({_id: "doc4", value : 4}).ok); + + var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=erlang/foo"); + var resp = JSON.parse(req.responseText); + T(resp.results.length === 2); + T(resp.results[0].id === "doc2"); + T(resp.results[1].id === "doc4"); + }); + }; |