Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scripts": {
"pretest": "node pretest.js",
"lint": "eslint .",
"test": "mocha test/*.test.js",
"test": "mocha test/mysql.discover.test.js",
"posttest": "npm run lint",
"postinstall": "patch-package"
},
Expand Down
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