2014-09-01 17:18:45 +02:00
|
|
|
'use strict';
|
|
|
|
|
2020-03-08 19:48:23 -04:00
|
|
|
const { expect } = require('chai');
|
|
|
|
|
2018-10-15 22:29:53 -04:00
|
|
|
const path = require('path');
|
|
|
|
const rimraf = require('rimraf');
|
2014-07-21 18:38:40 -04:00
|
|
|
|
2020-04-19 00:40:23 +02:00
|
|
|
module.exports = function (knex) {
|
2019-07-07 12:11:39 +03:00
|
|
|
describe('knex.seed.make', () => {
|
|
|
|
it('should create a new seed file with the make method', async () => {
|
|
|
|
const name = await knex.seed.make('test');
|
|
|
|
|
|
|
|
rimraf.sync(path.dirname(name));
|
|
|
|
expect(path.basename(name)).to.equal('test.js');
|
2014-07-21 18:38:40 -04:00
|
|
|
});
|
2014-07-21 19:27:26 -04:00
|
|
|
});
|
2014-07-21 18:38:40 -04:00
|
|
|
|
2019-07-07 12:11:39 +03:00
|
|
|
describe('knex.seed.run', () => {
|
|
|
|
it('should run all seed files in the configured seed directory', async () => {
|
|
|
|
const [data] = await knex.seed.run({
|
|
|
|
directory: 'test/integration/seed/test',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(path.basename(data[0])).to.equal('seed1.js');
|
|
|
|
expect(path.basename(data[1])).to.equal('seed2.js');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should run specific seed file in the configured seed directory', async () => {
|
|
|
|
const [data] = await knex.seed.run({
|
|
|
|
directory: 'test/integration/seed/test',
|
|
|
|
specific: 'seed2.js',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(data.length).to.equal(1);
|
|
|
|
expect(path.basename(data[0])).to.equal('seed2.js');
|
2014-07-21 18:38:40 -04:00
|
|
|
});
|
2014-07-21 19:27:26 -04:00
|
|
|
});
|
2014-09-01 17:18:45 +02:00
|
|
|
};
|