mirror of
https://github.com/knex/knex.git
synced 2025-07-10 18:41:18 +00:00
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
![]() |
var equal = require('assert').equal;
|
||
|
var path = require('path');
|
||
|
var rimraf = require('rimraf');
|
||
|
var Promise = require('../../../lib/promise');
|
||
|
|
||
|
module.exports = function(knex) {
|
||
|
|
||
|
require('rimraf').sync(path.join(__dirname, './seed'));
|
||
|
|
||
|
describe('knex.seed', function () {
|
||
|
|
||
|
describe('knex.seed.make', function() {
|
||
|
it('should create a new seed file with the make method', function () {
|
||
|
return knex.seed.make('test').then(function (name) {
|
||
|
expect(name).to.equal('test');
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe('knex.seed.run', function() {
|
||
|
it('should run all seed files in the configured seed directory', function() {
|
||
|
return knex.seed.run({directory: __dirname + '/test'}).then(function(data) {
|
||
|
expect(data[0].name).to.equal('seed1.js');
|
||
|
expect(data[1].name).to.equal('seed2.js');
|
||
|
});
|
||
|
});
|
||
|
|
||
|
it('should raise error if exports.seed function is not defined in seed file', function() {
|
||
|
return knex.seed.run({directory: __dirname + '/test'}).then(function(data) {
|
||
|
expect(data[0].name).to.equal('seed1.js');
|
||
|
expect(data[1].name).to.equal('seed2.js');
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|
||
|
after(function() {
|
||
|
rimraf.sync(path.join(__dirname, './seed'));
|
||
|
});
|
||
|
|
||
|
});
|
||
|
|
||
|
};
|