Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: cover when an empty array of models is returned #610

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/mysql.discover.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ describe('Discover models including other users', function() {
done(err);
} else {
let others = false;
assert(models.length > 0, 'some models returned');
models.find(function(m) {
assert(m.owner);
if (m.owner !== 'STRONGLOOP') {
Expand Down Expand Up @@ -143,6 +144,7 @@ describe('Discover model properties', function() {
console.error(err);
done(err);
} else {
assert(models.length > 0, 'some models returned');
models.forEach(function(m) { productProperties.push(m.columnName); });
productProperties.forEach((prop, index) => {
assert(productPropertiesInOrdinalOrder[index] === prop);
Expand All @@ -159,6 +161,7 @@ describe('Discover model properties', function() {
console.error(err);
done(err);
} else {
assert(models.length > 0, 'some models returned');
models.forEach(function(m) {
assert(m.tableName.toLowerCase() === 'product');
});
Expand All @@ -176,6 +179,7 @@ describe('Discover model primary keys', function() {
console.error(err);
done(err);
} else {
assert(models.length > 0, 'some models returned');
models.forEach(function(m) {
assert(m.tableName.toLowerCase() === 'product');
});
Expand All @@ -190,6 +194,7 @@ describe('Discover model primary keys', function() {
console.error(err);
done(err);
} else {
assert(models.length > 0, 'some models returned');
models.forEach(function(m) {
assert(m.tableName.toLowerCase() === 'product');
});
Expand All @@ -206,6 +211,7 @@ describe('Discover model foreign keys', function() {
console.error(err);
done(err);
} else {
assert(models.length > 0, 'some models returned');
models.forEach(function(m) {
assert(m.fkTableName === 'INVENTORY');
});
Expand All @@ -219,6 +225,7 @@ describe('Discover model foreign keys', function() {
console.error(err);
done(err);
} else {
assert(models.length > 0, 'some models returned');
models.forEach(function(m) {
assert(m.fkTableName === 'INVENTORY');
});
Expand All @@ -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) {
db.discoverModelProperties('product', function(err, models) {
if (err) return done(err);
assert(models.length > 0, 'some models returned');
models.forEach(function(model) {
assert(model.tableName.toLowerCase() === 'product');
assert(!model.generated, 'STRONGLOOP.PRODUCT table should not have generated (identity) columns');
Expand All @@ -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) {
db.discoverModelProperties('testgen', function(err, models) {
if (err) return done(err);
assert(models.length > 0, 'some models returned');
models.forEach(function(model) {
assert(model.tableName.toLowerCase() === 'testgen');
if (model.columnName === 'ID') {
Expand Down
Loading