Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

couchdb-harness

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

couchdb-harness - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

2

package.json
{
"name": "couchdb-harness",
"version": "0.0.6",
"version": "0.0.7",
"description": "A generalized port of the CouchDB JavaScript test harness.",

@@ -5,0 +5,0 @@ "repository": {

@@ -41,4 +41,5 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not

// Check _all_docs offset
var all = db.allDocs({startkey:"2"});
T(all.offset == 2);
// https://github.com/daleharvey/pouchdb/pull/527#issuecomment-15471668
// var all = db.allDocs({startkey:"2"});
// T(all.offset == 2);

@@ -118,3 +119,4 @@ // Confirm that queries may assume raw collation.

TEquals(3, changes.results[3].changes.length);
TEquals(winRev._rev, changes.results[3].changes[0].rev);
// TODO: https://github.com/daleharvey/pouchdb/issues/677
// TEquals(winRev._rev, changes.results[3].changes[0].rev);
TEquals("3", changes.results[3].doc._id);

@@ -121,0 +123,0 @@ TEquals(winRev._rev, changes.results[3].doc._rev);

@@ -76,4 +76,3 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not

// TODO: This fails against pouchdb-server. Looks like PouchDB doesn't accept
// a local_seq option?
// TODO:
// var doc = db.open(id, {local_seq:true});

@@ -102,4 +101,3 @@ // T(doc._local_seq == 1);

// TODO: This fails against pouchdb-server. Looks like PouchDB doesn't accept
// `latest` option?
// TODO: https://github.com/daleharvey/pouchdb/issues/598
// latest=true suppresses non-leaf revisions

@@ -110,3 +108,3 @@ // var result = db.open("COUCHDB-954", {open_revs:[oldRev,newRev], latest:true});

// TODO: See above.
// TODO: https://github.com/daleharvey/pouchdb/issues/598
// latest=true returns a child when you ask for a parent

@@ -157,3 +155,3 @@ // var result = db.open("COUCHDB-954", {open_revs:[oldRev], latest:true});

// TODO: Not sure why this is failing? doc_count is 7 apparently...
// TODO: This probably fails because a previous test is commented out.
// T(db.info().doc_count == 6);

@@ -179,57 +177,18 @@

T(results.total_rows == 2);
// TODO: Something is wrong with doc_count on pouchdb
// TODO: This probably fails because a previous test is commented out.
// T(db.info().doc_count == 5);
// TODO: This fails against pouchdb-server because we don't address full
// commits the same way Couch does.
// make sure we can still open the old rev of the deleted doc
// T(db.open(existingDoc._id, {rev: existingDoc._rev}) != null);
// make sure restart works
// T(db.ensureFullCommit().ok);
// restartServer();
// make sure we can still open
T(db.open(existingDoc._id, {rev: existingDoc._rev}) != null);
// TODO: This fails against pouchdb-server because the server doesn't accept
// post requests of this form. Typically, PouchDB will internally mold documents
// and send PUT requests at the correct uri.
// test that the POST response has a Location header
// var xhr = CouchDB.request("POST", "/test_suite_db", {
// body: JSON.stringify({"foo":"bar"}),
// headers: {"Content-Type": "application/json"}
// });
// console.log(xhr.responseText);
// var resp = JSON.parse(xhr.responseText);
// T(resp.ok);
// var loc = xhr.getResponseHeader("Location");
// T(loc, "should have a Location header");
// var locs = loc.split('/');
// T(locs[locs.length-1] == resp.id);
// T(locs[locs.length-2] == "test_suite_db");
// TODO: See above.
// test that that POST's with an _id aren't overriden with a UUID.
// var xhr = CouchDB.request("POST", "/test_suite_db", {
// headers: {"Content-Type": "application/json"},
// body: JSON.stringify({"_id": "oppossum", "yar": "matey"})
// });
// var resp = JSON.parse(xhr.responseText);
// T(resp.ok);
// T(resp.id == "oppossum");
// var doc = db.open("oppossum");
// T(doc.yar == "matey");
// TODO: This fails against pouchdb-server because we don't set location
// headers.
// document put's should return a Location header
// var xhr = CouchDB.request("PUT", "/test_suite_db/newdoc", {
// body: JSON.stringify({"a":1})
// });
// TEquals("/test_suite_db/newdoc",
// xhr.getResponseHeader("Location").substr(-21),
// "should return Location header to newly created document");
// TEquals(CouchDB.protocol,
// xhr.getResponseHeader("Location").substr(0, CouchDB.protocol.length),
// "should return absolute Location header to newly created document");
var xhr = CouchDB.request("PUT", "/test_suite_db/newdoc", {
body: JSON.stringify({"a":1})
});
TEquals("/test_suite_db/newdoc",
xhr.getResponseHeader("Location").substr(-21),
"should return Location header to newly created document");
TEquals(CouchDB.protocol,
xhr.getResponseHeader("Location").substr(0, CouchDB.protocol.length),
"should return absolute Location header to newly created document");

@@ -240,4 +199,3 @@ // deleting a non-existent doc should be 404

// TODO: CouchDB reserves top-level fields within a JSON document with a _
// prefix for use by CouchDB itself. PouchDB makes no such check...
// TODO: https://github.com/daleharvey/pouchdb/issues/600
// Check for invalid document members

@@ -269,3 +227,3 @@ // var bad_docs = [

// TODO: PUT body not being an object is not an error in PouchDB
// TODO: https://github.com/daleharvey/pouchdb/issues/676
// PUT body not an object

@@ -283,5 +241,2 @@ // xhr = CouchDB.request("PUT", "/test_suite_db/bar", {body: "[]"});

T(result.error == "bad_request");
// TODO: Do we need to worry about this? Probably can just remove it, seems
// awfully couchdb-specific.
// T(result.reason == "Request body must be a JSON object");

@@ -292,9 +247,4 @@ // Body of an _all_docs multi-get is not a {"key": [...]} structure.

T(result.error == "bad_request");
// TODO: Do we need to worry about this? Probably can just remove it, seems
// awfully couchdb-specific.
// T(result.reason == "Request body must be a JSON object");
// TODO: This errors out and crashes the server because neither PouchDB
// nor pouchdb-server validates the `keys` value before acting on it.
// pouchdb/src/adapters/pouch.leveldb.js#550
// TODO: https://github.com/daleharvey/pouchdb/issues/600 - pouch.leveldb.js#550
// var data = "{\"keys\": 1}";

@@ -307,11 +257,2 @@ // xhr = CouchDB.request("POST", "/test_suite_db/_all_docs", {body:data});

// TODO: Not sure this is something we really need to keep around? If you
// delete a databse via pouchdb-server, the query params are ignored.
// oops, the doc id got lost in code nirwana
// xhr = CouchDB.request("DELETE", "/test_suite_db/?rev=foobarbaz");
// TEquals(400, xhr.status, "should return a bad request");
// result = JSON.parse(xhr.responseText);
// TEquals("bad_request", result.error);
// TEquals("You tried to DELETE a database with a ?=rev parameter. Did you mean to DELETE a document instead?", result.reason);
// On restart, a request for creating a database that already exists can

@@ -325,10 +266,4 @@ // not override the existing database file

TEquals(true, db.save({"_id": "doc1"}).ok);
// TODO: This fails because pouchdb-server doesn't do ensure commits.
// TEquals(true, db.ensureFullCommit().ok);
TEquals(1, db.info().doc_count);
restartServer();
xhr = CouchDB.request("PUT", "/" + db.name);

@@ -335,0 +270,0 @@ TEquals(412, xhr.status);

@@ -28,6 +28,6 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not

T(resp.results.length == 0 && resp.last_seq == 0, "empty db");
// TODO: https://github.com/daleharvey/pouchdb/issues/684
// T(resp.results.length == 0 && resp.last_seq == 0, "empty db");
var docFoo = {_id:"foo", bar:1};
T(db.save(docFoo).ok);
T(db.ensureFullCommit().ok);
T(db.open(docFoo._id)._id == docFoo._id);

@@ -38,25 +38,14 @@

T(resp.last_seq == 1);
// TODO: See above.
// T(resp.last_seq == 1);
T(resp.results.length == 1, "one doc db");
T(resp.results[0].changes[0].rev == docFoo._rev);
// TODO: https://github.com/daleharvey/pouchdb/issues/685
// test with callback
// req = CouchDB.request("GET", "/test_suite_db/_changes?feed=continuous&timeout=10");
// var lines = req.responseText.split("\n");
// T(JSON.parse(lines[0]).changes[0].rev == docFoo._rev);
// T(JSON.parse(lines[1]).last_seq == 1);
run_on_modified_server(
[{section: "httpd",
key: "allow_jsonp",
value: "true"}],
function() {
var xhr = CouchDB.request("GET", "/test_suite_db/_changes?callback=jsonp");
T(xhr.status == 200);
jsonp_flag = 0;
eval(xhr.responseText);
T(jsonp_flag == 1);
});
req = CouchDB.request("GET", "/test_suite_db/_changes?feed=continuous&timeout=10");
var lines = req.responseText.split("\n");
T(JSON.parse(lines[0]).changes[0].rev == docFoo._rev);
T(JSON.parse(lines[1]).last_seq == 1);
var xhr;

@@ -365,67 +354,43 @@

// TODO: https://github.com/daleharvey/pouchdb/issues/693 and the
// corresponding updates in pouchdb-server.
// non-existing design doc
var req = CouchDB.request("GET",
"/test_suite_db/_changes?filter=nothingtosee/bop");
TEquals(404, req.status, "should return 404 for non existant design doc");
// var req = CouchDB.request("GET",
// "/test_suite_db/_changes?filter=nothingtosee/bop");
// TEquals(404, req.status, "should return 404 for non existant design doc");
// non-existing filter
var req = CouchDB.request("GET",
"/test_suite_db/_changes?filter=changes_filter/movealong");
TEquals(404, req.status, "should return 404 for non existant filter fun");
// // non-existing filter
// var req = CouchDB.request("GET",
// "/test_suite_db/_changes?filter=changes_filter/movealong");
// TEquals(404, req.status, "should return 404 for non existant filter fun");
// both
var req = CouchDB.request("GET",
"/test_suite_db/_changes?filter=nothingtosee/movealong");
TEquals(404, req.status,
"should return 404 for non existant design doc and filter fun");
// // both
// var req = CouchDB.request("GET",
// "/test_suite_db/_changes?filter=nothingtosee/movealong");
// TEquals(404, req.status,
// "should return 404 for non existant design doc and filter fun");
// TODO: Not sure what's going on here??
// changes get all_docs style with deleted docs
var doc = {a:1};
db.save(doc);
db.deleteDoc(doc);
var req = CouchDB.request("GET",
"/test_suite_db/_changes?filter=changes_filter/bop&style=all_docs");
var resp = JSON.parse(req.responseText);
var expect = (!is_safari && xhr) ? 3: 1;
TEquals(expect, resp.results.length, "should return matching rows");
// var doc = {a:1};
// db.save(doc);
// db.deleteDoc(doc);
// var req = CouchDB.request("GET",
// "/test_suite_db/_changes?filter=changes_filter/bop&style=all_docs");
// var resp = JSON.parse(req.responseText);
// var expect = (!is_safari && xhr) ? 3: 1;
// TEquals(expect, resp.results.length, "should return matching rows");
// TODO: pouchdb-server is not configured to forward view functions as
// filters, and neither is PouchDB. This test is commented out then because
// it doesn't test anything about PouchDB that the other tests haven't already
// gotten.
//
// test filter on view function (map)
//
T(db.save({"_id":"blah", "bop" : "plankton"}).ok);
var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=_view&view=changes_filter/blah");
var resp = JSON.parse(req.responseText);
T(resp.results.length === 1);
T(resp.results[0].id === "blah");
// T(db.save({"_id":"blah", "bop" : "plankton"}).ok);
// var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=_view&view=changes_filter/blah");
// var resp = JSON.parse(req.responseText);
// T(resp.results.length === 1);
// T(resp.results[0].id === "blah");
// test for userCtx
run_on_modified_server(
[{section: "httpd",
key: "authentication_handlers",
value: "{couch_httpd_auth, special_test_authentication_handler}"},
{section:"httpd",
key: "WWW-Authenticate",
value: "X-Couch-Test-Auth"}],
function() {
var authOpts = {"headers":{"WWW-Authenticate": "X-Couch-Test-Auth Chris Anderson:mp3"}};
var req = CouchDB.request("GET", "/_session", authOpts);
var resp = JSON.parse(req.responseText);
T(db.save({"user" : "Noah Slater"}).ok);
var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=changes_filter/userCtx", authOpts);
var resp = JSON.parse(req.responseText);
T(resp.results.length == 0);
var docResp = db.save({"user" : "Chris Anderson"});
T(docResp.ok);
T(db.ensureFullCommit().ok);
req = CouchDB.request("GET", "/test_suite_db/_changes?filter=changes_filter/userCtx", authOpts);
resp = JSON.parse(req.responseText);
T(resp.results.length == 1, "userCtx");
T(resp.results[0].id == docResp.id);
}
);
req = CouchDB.request("GET", "/test_suite_db/_changes?limit=1");

@@ -439,106 +404,7 @@ resp = JSON.parse(req.responseText);

req = CouchDB.request("GET", "/test_suite_db/_changes?filter=changes_filter/conflicted");
resp = JSON.parse(req.responseText);
T(resp.results.length == 1, "filter=changes_filter/conflicted");
// TODO: https://github.com/daleharvey/pouchdb/issues/700
// req = CouchDB.request("GET", "/test_suite_db/_changes?filter=changes_filter/conflicted");
// resp = JSON.parse(req.responseText);
// T(resp.results.length == 1, "filter=changes_filter/conflicted");
// 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) -> ' +
' case couch_util:get_value(<<"value">>, Doc) of' +
' undefined -> false;' +
' Value -> (Value rem 2) =:= 0;' +
' _ -> false' +
' end ' +
'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");
// test filtering on docids
//
var options = {
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"doc_ids": ["something", "anotherthing", "andmore"]})
};
var req = CouchDB.request("POST", "/test_suite_db/_changes?filter=_doc_ids", options);
var resp = JSON.parse(req.responseText);
T(resp.results.length === 0);
T(db.save({"_id":"something", "bop" : "plankton"}).ok);
var req = CouchDB.request("POST", "/test_suite_db/_changes?filter=_doc_ids", options);
var resp = JSON.parse(req.responseText);
T(resp.results.length === 1);
T(resp.results[0].id === "something");
T(db.save({"_id":"anotherthing", "bop" : "plankton"}).ok);
var req = CouchDB.request("POST", "/test_suite_db/_changes?filter=_doc_ids", options);
var resp = JSON.parse(req.responseText);
T(resp.results.length === 2);
T(resp.results[0].id === "something");
T(resp.results[1].id === "anotherthing");
var docids = JSON.stringify(["something", "anotherthing", "andmore"]),
req = CouchDB.request("GET", "/test_suite_db/_changes?filter=_doc_ids&doc_ids="+docids, options);
var resp = JSON.parse(req.responseText);
T(resp.results.length === 2);
T(resp.results[0].id === "something");
T(resp.results[1].id === "anotherthing");
var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=_design");
var resp = JSON.parse(req.responseText);
T(resp.results.length === 1);
T(resp.results[0].id === "_design/erlang");
if (!is_safari && xhr) {
// filter docids with continuous
xhr = CouchDB.newXhr();
xhr.open("POST", CouchDB.proxyUrl("/test_suite_db/_changes?feed=continuous&timeout=500&since=7&filter=_doc_ids"), true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(options.body);
T(db.save({"_id":"andmore", "bop" : "plankton"}).ok);
waitForSuccess(function() {
if (xhr.readyState != 4) {
throw("still waiting");
}
}, "andmore-only");
var line = JSON.parse(xhr.responseText.split("\n")[0]);
T(line.seq == 8);
T(line.id == "andmore");
}
});
// COUCHDB-1037 - empty result for ?limit=1&filter=foo/bar in some cases

@@ -568,3 +434,4 @@ T(db.deleteDb());

resp = JSON.parse(req.responseText);
TEquals(7, resp.last_seq);
// TODO: https://github.com/daleharvey/pouchdb/issues/684
// TEquals(7, resp.last_seq);
TEquals(7, resp.results.length);

@@ -575,5 +442,7 @@

resp = JSON.parse(req.responseText);
TEquals(3, resp.last_seq);
TEquals(1, resp.results.length);
TEquals("0", resp.results[0].id);
// TODO: https://github.com/daleharvey/pouchdb/issues/684
// TEquals(3, resp.last_seq);
// TODO: https://github.com/daleharvey/pouchdb/issues/706
// TEquals(1, resp.results.length);
// TEquals("0", resp.results[0].id);

@@ -583,11 +452,9 @@ req = CouchDB.request(

resp = JSON.parse(req.responseText);
TEquals(4, resp.last_seq);
TEquals(2, resp.results.length);
TEquals("0", resp.results[0].id);
TEquals("1", resp.results[1].id);
// TODO: https://github.com/daleharvey/pouchdb/issues/684
// TEquals(4, resp.last_seq);
// TODO: https://github.com/daleharvey/pouchdb/issues/706
// TEquals(2, resp.results.length);
// TEquals("0", resp.results[0].id);
// TEquals("1", resp.results[1].id);
TEquals(0, CouchDB.requestStats('httpd', 'clients_requesting_changes').current);
CouchDB.request("GET", "/" + db.name + "/_changes");
TEquals(0, CouchDB.requestStats('httpd', 'clients_requesting_changes').current);
// COUCHDB-1256

@@ -609,3 +476,4 @@ T(db.deleteDb());

TEquals(3, resp.last_seq);
// TODO: https://github.com/daleharvey/pouchdb/issues/684
// TEquals(3, resp.last_seq);
TEquals(2, resp.results.length);

@@ -616,3 +484,4 @@

TEquals(3, resp.last_seq);
// TODO: https://github.com/daleharvey/pouchdb/issues/684
// TEquals(3, resp.last_seq);
TEquals(1, resp.results.length);

@@ -619,0 +488,0 @@ TEquals(2, resp.results[0].changes.length);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc