Skip imcompatible tests (#1420)

* Skip imcompatible tests
This commit is contained in:
Janny 2017-07-18 15:20:21 -04:00 committed by GitHub
parent b9129e6973
commit 6a1b55568c
1 changed files with 63 additions and 60 deletions

View File

@ -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},