[test/elasticsearch][xs]: disable ES backend write tests as they needed a running local ES server.

This commit is contained in:
Rufus Pollock
2012-10-14 18:50:39 +01:00
parent 78ecb0ff42
commit d3b8f39213

View File

@@ -196,52 +196,53 @@ test("query", function() {
$.ajax.restore(); $.ajax.restore();
}); });
test("write", function() { // DISABLED - this test requires ElasticSearch to be running locally
var url = 'http://localhost:9200/recline-test/es-write'; // test("write", function() {
var backend = new recline.Backend.ElasticSearch.Wrapper(url); // var url = 'http://localhost:9200/recline-test/es-write';
stop(); // var backend = new recline.Backend.ElasticSearch.Wrapper(url);
// stop();
var id = parseInt(Math.random()*100000000).toString(); //
var rec = { // var id = parseInt(Math.random()*100000000).toString();
id: id, // var rec = {
title: 'my title' // id: id,
}; // title: 'my title'
var jqxhr = backend.upsert(rec); // };
jqxhr.done(function(data) { // var jqxhr = backend.upsert(rec);
ok(data.ok); // jqxhr.done(function(data) {
equal(data._id, id); // ok(data.ok);
equal(data._type, 'es-write'); // equal(data._id, id);
equal(data._version, 1); // equal(data._type, 'es-write');
// equal(data._version, 1);
// update //
rec.title = 'new title'; // // update
var jqxhr = backend.upsert(rec); // rec.title = 'new title';
jqxhr.done(function(data) { // var jqxhr = backend.upsert(rec);
equal(data._version, 2); // jqxhr.done(function(data) {
// equal(data._version, 2);
// delete //
var jqxhr = backend.remove(rec.id); // // delete
jqxhr.done(function(data) { // var jqxhr = backend.remove(rec.id);
ok(data.ok); // jqxhr.done(function(data) {
rec = null; // ok(data.ok);
// rec = null;
// try to get ... //
var jqxhr = backend.get(id); // // try to get ...
jqxhr.done(function(data) { // var jqxhr = backend.get(id);
// should not be here // jqxhr.done(function(data) {
ok(false, 'Should have got 404'); // // should not be here
}).error(function(error) { // ok(false, 'Should have got 404');
equal(error.status, 404); // }).error(function(error) {
start(); // equal(error.status, 404);
}); // start();
}); // });
}); // });
}).fail(function(error) { // });
console.log(error); // }).fail(function(error) {
ok(false, 'Basic request failed - is ElasticSearch running locally on port 9200 (required for this test!)'); // console.log(error);
start(); // ok(false, 'Basic request failed - is ElasticSearch running locally on port 9200 (required for this test!)');
}); // start();
}); // });
// });
// ================================================== // ==================================================
@@ -289,63 +290,64 @@ test("query", function() {
$.ajax.restore(); $.ajax.restore();
}); });
test("write", function() { // DISABLED - this test requires ElasticSearch to be running locally
var dataset = new recline.Model.Dataset({ // test("write", function() {
url: 'http://localhost:9200/recline-test/es-write', // var dataset = new recline.Model.Dataset({
backend: 'elasticsearch' // url: 'http://localhost:9200/recline-test/es-write',
}); // backend: 'elasticsearch'
// });
stop(); //
// stop();
var id = parseInt(Math.random()*100000000).toString(); //
var rec = new recline.Model.Record({ // var id = parseInt(Math.random()*100000000).toString();
id: id, // var rec = new recline.Model.Record({
title: 'my title' // id: id,
}); // title: 'my title'
dataset.records.add(rec); // });
// have to do this explicitly as we not really supporting adding new items atm // dataset.records.add(rec);
dataset._changes.creates.push(rec.toJSON()); // // have to do this explicitly as we not really supporting adding new items atm
var jqxhr = dataset.save(); // dataset._changes.creates.push(rec.toJSON());
jqxhr.done(function(data) { // var jqxhr = dataset.save();
ok(data.ok); // jqxhr.done(function(data) {
equal(data._id, id); // ok(data.ok);
equal(data._type, 'es-write'); // equal(data._id, id);
equal(data._version, 1); // equal(data._type, 'es-write');
// equal(data._version, 1);
// update //
rec.set({title: 'new title'}); // // update
// again set up by hand ... // rec.set({title: 'new title'});
dataset._changes.creates = []; // // again set up by hand ...
dataset._changes.updates.push(rec.toJSON()); // dataset._changes.creates = [];
var jqxhr = dataset.save(); // dataset._changes.updates.push(rec.toJSON());
jqxhr.done(function(data) { // var jqxhr = dataset.save();
equal(data._version, 2); // jqxhr.done(function(data) {
// equal(data._version, 2);
// delete //
dataset._changes.updates = 0; // // delete
dataset._changes.deletes.push(rec.toJSON()); // dataset._changes.updates = 0;
var jqxhr = dataset.save(); // dataset._changes.deletes.push(rec.toJSON());
jqxhr.done(function(data) { // var jqxhr = dataset.save();
ok(data.ok); // jqxhr.done(function(data) {
rec = null; // ok(data.ok);
// rec = null;
// try to get ... //
var es = new recline.Backend.ElasticSearch.Wrapper(dataset.get('url')); // // try to get ...
var jqxhr = es.get(id); // var es = new recline.Backend.ElasticSearch.Wrapper(dataset.get('url'));
jqxhr.done(function(data) { // var jqxhr = es.get(id);
// should not be here // jqxhr.done(function(data) {
ok(false, 'Should have got 404'); // // should not be here
}).error(function(error) { // ok(false, 'Should have got 404');
equal(error.status, 404); // }).error(function(error) {
start(); // equal(error.status, 404);
}); // start();
}); // });
}); // });
}).fail(function(error) { // });
console.log(error); // }).fail(function(error) {
ok(false, 'Basic request failed - is ElasticSearch running locally on port 9200 (required for this test!)'); // console.log(error);
start(); // ok(false, 'Basic request failed - is ElasticSearch running locally on port 9200 (required for this test!)');
}); // start();
}); // });
// });
})(this.jQuery); })(this.jQuery);