test: cover when an empty array of models is returned
Signed-off-by: Muhammad Aaqil <aaqilcs102@gmail.com>
This commit is contained in:
parent
b057c20fe2
commit
41f55f9272
|
@ -109,6 +109,7 @@ describe('Discover models including other users', function() {
|
||||||
done(err);
|
done(err);
|
||||||
} else {
|
} else {
|
||||||
let others = false;
|
let others = false;
|
||||||
|
assert(models.length > 0, 'some models returned');
|
||||||
models.find(function(m) {
|
models.find(function(m) {
|
||||||
assert(m.owner);
|
assert(m.owner);
|
||||||
if (m.owner !== 'STRONGLOOP') {
|
if (m.owner !== 'STRONGLOOP') {
|
||||||
|
@ -143,6 +144,7 @@ describe('Discover model properties', function() {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
done(err);
|
done(err);
|
||||||
} else {
|
} else {
|
||||||
|
assert(models.length > 0, 'some models returned');
|
||||||
models.forEach(function(m) { productProperties.push(m.columnName); });
|
models.forEach(function(m) { productProperties.push(m.columnName); });
|
||||||
productProperties.forEach((prop, index) => {
|
productProperties.forEach((prop, index) => {
|
||||||
assert(productPropertiesInOrdinalOrder[index] === prop);
|
assert(productPropertiesInOrdinalOrder[index] === prop);
|
||||||
|
@ -159,6 +161,7 @@ describe('Discover model properties', function() {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
done(err);
|
done(err);
|
||||||
} else {
|
} else {
|
||||||
|
assert(models.length > 0, 'some models returned');
|
||||||
models.forEach(function(m) {
|
models.forEach(function(m) {
|
||||||
assert(m.tableName.toLowerCase() === 'product');
|
assert(m.tableName.toLowerCase() === 'product');
|
||||||
});
|
});
|
||||||
|
@ -176,6 +179,7 @@ describe('Discover model primary keys', function() {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
done(err);
|
done(err);
|
||||||
} else {
|
} else {
|
||||||
|
assert(models.length > 0, 'some models returned');
|
||||||
models.forEach(function(m) {
|
models.forEach(function(m) {
|
||||||
assert(m.tableName.toLowerCase() === 'product');
|
assert(m.tableName.toLowerCase() === 'product');
|
||||||
});
|
});
|
||||||
|
@ -190,6 +194,7 @@ describe('Discover model primary keys', function() {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
done(err);
|
done(err);
|
||||||
} else {
|
} else {
|
||||||
|
assert(models.length > 0, 'some models returned');
|
||||||
models.forEach(function(m) {
|
models.forEach(function(m) {
|
||||||
assert(m.tableName.toLowerCase() === 'product');
|
assert(m.tableName.toLowerCase() === 'product');
|
||||||
});
|
});
|
||||||
|
@ -206,6 +211,7 @@ describe('Discover model foreign keys', function() {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
done(err);
|
done(err);
|
||||||
} else {
|
} else {
|
||||||
|
assert(models.length > 0, 'some models returned');
|
||||||
models.forEach(function(m) {
|
models.forEach(function(m) {
|
||||||
assert(m.fkTableName === 'INVENTORY');
|
assert(m.fkTableName === 'INVENTORY');
|
||||||
});
|
});
|
||||||
|
@ -219,6 +225,7 @@ describe('Discover model foreign keys', function() {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
done(err);
|
done(err);
|
||||||
} else {
|
} else {
|
||||||
|
assert(models.length > 0, 'some models returned');
|
||||||
models.forEach(function(m) {
|
models.forEach(function(m) {
|
||||||
assert(m.fkTableName === 'INVENTORY');
|
assert(m.fkTableName === 'INVENTORY');
|
||||||
});
|
});
|
||||||
|
@ -232,6 +239,7 @@ describe('Discover model generated columns', function() {
|
||||||
it('should return an array of columns for STRONGLOOP.PRODUCT and none of them is generated', function(done) {
|
it('should return an array of columns for STRONGLOOP.PRODUCT and none of them is generated', function(done) {
|
||||||
db.discoverModelProperties('product', function(err, models) {
|
db.discoverModelProperties('product', function(err, models) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
|
assert(models.length > 0, 'some models returned');
|
||||||
models.forEach(function(model) {
|
models.forEach(function(model) {
|
||||||
assert(model.tableName.toLowerCase() === 'product');
|
assert(model.tableName.toLowerCase() === 'product');
|
||||||
assert(!model.generated, 'STRONGLOOP.PRODUCT table should not have generated (identity) columns');
|
assert(!model.generated, 'STRONGLOOP.PRODUCT table should not have generated (identity) columns');
|
||||||
|
@ -242,6 +250,7 @@ describe('Discover model generated columns', function() {
|
||||||
it('should return an array of columns for STRONGLOOP.TESTGEN and the first is generated', function(done) {
|
it('should return an array of columns for STRONGLOOP.TESTGEN and the first is generated', function(done) {
|
||||||
db.discoverModelProperties('testgen', function(err, models) {
|
db.discoverModelProperties('testgen', function(err, models) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
|
assert(models.length > 0, 'some models returned');
|
||||||
models.forEach(function(model) {
|
models.forEach(function(model) {
|
||||||
assert(model.tableName.toLowerCase() === 'testgen');
|
assert(model.tableName.toLowerCase() === 'testgen');
|
||||||
if (model.columnName === 'ID') {
|
if (model.columnName === 'ID') {
|
||||||
|
|
Loading…
Reference in New Issue