From 6a1b55568cab3fabd7bd5823f8749684ad75a1fc Mon Sep 17 00:00:00 2001 From: Janny Date: Tue, 18 Jul 2017 15:20:21 -0400 Subject: [PATCH] Skip imcompatible tests (#1420) * Skip imcompatible tests --- test/manipulation.test.js | 123 +++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/test/manipulation.test.js b/test/manipulation.test.js index 88b086b5..08878130 100644 --- a/test/manipulation.test.js +++ b/test/manipulation.test.js @@ -397,39 +397,41 @@ describe('manipulation', function() { .catch(done); }); - it('should save existing object', function(done) { + bdd.itIf(connectorCapabilities.cloudantCompatible !== false, + 'should save existing object', function(done) { // Cloudant could not guarantee findOne always return the same item - Person.findOne(function(err, p) { - if (err) return done(err); - p.name = 'Hans'; - p.save(function(err) { + Person.findOne(function(err, p) { if (err) return done(err); - p.name.should.equal('Hans'); - Person.findOne(function(err, p) { + p.name = 'Hans'; + p.save(function(err) { if (err) return done(err); p.name.should.equal('Hans'); - done(); + Person.findOne(function(err, p) { + if (err) return done(err); + p.name.should.equal('Hans'); + done(); + }); }); }); }); - }); - it('should save existing object (promise variant)', function(done) { + bdd.itIf(connectorCapabilities.cloudantCompatible !== false, + 'should save existing object (promise variant)', function(done) { // Cloudant could not guarantee findOne always return the same item - Person.findOne() - .then(function(p) { - p.name = 'Fritz'; - return p.save() - .then(function() { - return Person.findOne() - .then(function(p) { - p.name.should.equal('Fritz'); - done(); - }); - }); - }) - .catch(done); - }); + Person.findOne() + .then(function(p) { + p.name = 'Fritz'; + return p.save() + .then(function() { + return Person.findOne() + .then(function(p) { + p.name.should.equal('Fritz'); + done(); + }); + }); + }) + .catch(done); + }); it('should save invalid object (skipping validation)', function(done) { Person.findOne(function(err, p) { @@ -577,7 +579,8 @@ describe('manipulation', function() { }); }); - it('should discard undefined values before strict validation', + bdd.itIf(connectorCapabilities.cloudantCompatible !== false, + 'should discard undefined values before strict validation', function(done) { Person.definition.settings.strict = true; Person.findById(person.id, function(err, p) { @@ -1000,7 +1003,10 @@ describe('manipulation', function() { }); }); - if (!getSchema().connector.replaceById) { + var hasReplaceById = connectorCapabilities.cloudantCompatible !== false && + !!getSchema().connector.replaceById; + + if (!hasReplaceById) { describe.skip('replaceById - not implemented', function() {}); } else { describe('replaceOrCreate', function() { @@ -1223,8 +1229,6 @@ describe('manipulation', function() { }); } - var hasReplaceById = !!getSchema().connector.replaceById; - bdd.describeIf(hasReplaceById && connectorCapabilities.supportForceId !== false, 'replaceOrCreate ' + 'when forceId is true', function() { var Post, unknownId; @@ -1273,7 +1277,7 @@ describe('manipulation', function() { }); }); - if (!getSchema().connector.replaceById) { + if (!hasReplaceById) { describe.skip('replaceAttributes/replaceById - not implemented', function() {}); } else { describe('replaceAttributes', function() { @@ -1470,7 +1474,6 @@ describe('manipulation', function() { }); } - hasReplaceById = !!getSchema().connector.replaceById; bdd.describeIf(hasReplaceById, 'replaceById', function() { var Post; before(function(done) { @@ -1861,23 +1864,23 @@ describe('manipulation', function() { }); bdd.itIf(connectorCapabilities.supportStrictDelete !== false, 'should allow delete(id) - ' + - 'fail with error', function(done) { - Person.settings.strictDelete = true; - Person.findOne(function(err, u) { - if (err) return done(err); - u.delete(function(err, info) { + 'fail with error', function(done) { + Person.settings.strictDelete = true; + Person.findOne(function(err, u) { if (err) return done(err); - info.should.have.property('count', 1); - u.delete(function(err) { - should.exist(err); - err.message.should.equal('No instance with id ' + u.id + ' found for Person'); - err.should.have.property('code', 'NOT_FOUND'); - err.should.have.property('statusCode', 404); - done(); + u.delete(function(err, info) { + if (err) return done(err); + info.should.have.property('count', 1); + u.delete(function(err) { + should.exist(err); + err.message.should.equal('No instance with id ' + u.id + ' found for Person'); + err.should.have.property('code', 'NOT_FOUND'); + err.should.have.property('statusCode', 404); + done(); + }); }); }); }); - }); }); describe('initialize', function() { @@ -2202,26 +2205,26 @@ describe('manipulation', function() { }); }); - bdd.itIf(connectorCapabilities.updateWithoutId !== false, 'should update all instances when ' + - 'the where condition is not provided', function(done) { - filterHarry = connectorCapabilities.deleteWithOtherThanId === false ? - {id: idHarry} : {name: 'Harry Hoe'}; - filterBrett = connectorCapabilities.deleteWithOtherThanId === false ? - {id: idBrett} : {name: 'Brett Boe'}; - Person.update(filterHarry, function(err, info) { - if (err) return done(err); - info.should.have.property('count', 5); - Person.find({where: filterBrett}, function(err, people) { + bdd.itIf(connectorCapabilities.updateWithoutId !== false, + 'should update all instances when the where condition is not provided', function(done) { + filterHarry = connectorCapabilities.deleteWithOtherThanId === false ? + {id: idHarry} : {name: 'Harry Hoe'}; + filterBrett = connectorCapabilities.deleteWithOtherThanId === false ? + {id: idBrett} : {name: 'Brett Boe'}; + Person.update(filterHarry, function(err, info) { if (err) return done(err); - people.should.be.empty(); - Person.find({where: filterHarry}, function(err, people) { + info.should.have.property('count', 5); + Person.find({where: filterBrett}, function(err, people) { if (err) return done(err); - people.should.have.length(5); - done(); + people.should.be.empty(); + Person.find({where: filterHarry}, function(err, people) { + if (err) return done(err); + people.should.have.length(5); + done(); + }); }); }); }); - }); bdd.itIf(connectorCapabilities.ignoreUndefinedConditionValue !== false, 'should ignore where ' + 'conditions with undefined values', function(done) { @@ -2248,9 +2251,9 @@ describe('manipulation', function() { }); describe('upsertWithWhere', function() { - var ds = getSchema(); - var Person; + var ds, Person; before('prepare "Person" model', function(done) { + ds = getSchema(); Person = ds.define('Person', { id: {type: Number, id: true}, name: {type: String},