-
Notifications
You must be signed in to change notification settings - Fork 1
/
seed-test.js
60 lines (52 loc) · 1.81 KB
/
seed-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env jake
'use strict';
/* eslint-disable no-undef */
const path = require('path');
const {
assertExec,
assertExecError,
test,
} = require('../../jake-util/helpers/migration-test-helper');
const { assert } = require('chai');
const KNEX = path.normalize(__dirname + '/../../../bin/cli.js');
const taskList = [];
/* * * TESTS * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
test(taskList, 'seed:run prints non verbose logs', (temp) => {
return assertExec(
`node ${KNEX} seed:run --knexfile=test/jake-util/seeds-knexfile.js --knexpath=../knex.js`
).then(({ stdout }) => {
assert.include(stdout, 'Ran 2 seed files');
assert.notInclude(stdout, 'first.js');
assert.notInclude(stdout, 'second.js');
});
});
test(taskList, 'seed:run prints verbose logs', (temp) => {
return assertExec(
`node ${KNEX} seed:run --knexfile=test/jake-util/seeds-knexfile.js --knexpath=../knex.js --verbose`
).then(({ stdout }) => {
assert.include(stdout, 'Ran 2 seed files');
assert.include(stdout, 'first.js');
assert.include(stdout, 'second.js');
});
});
test(taskList, 'seed:run runs specific file', () => {
return assertExec(
`node ${KNEX} seed:run --knexfile=test/jake-util/seeds-knexfile.js --knexpath=../knex.js --specific=second.js`
).then(({ stdout }) => {
assert.include(stdout, 'Ran 1 seed files');
assert.notInclude(stdout, 'first.js');
assert.notInclude(stdout, 'second.js');
});
});
test(taskList, 'Handles seeding errors correctly', (temp) => {
return assertExecError(
`node ${KNEX} seed:run --knexfile=test/jake-util/seeds-error-knexfile.js --knexpath=../knex.js`
).then((err) => {
assert.include(err, 'Error while executing');
assert.include(err, 'seeds.js');
assert.include(err, 'Boom');
});
});
module.exports = {
taskList,
};