Skip to content

Commit

Permalink
add test for migrate with not initialized env
Browse files Browse the repository at this point in the history
  • Loading branch information
okv committed Dec 6, 2019
1 parent 4d5e5fe commit fec452a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* IMPORTANT
* This snapshot file is auto-generated, but designed for humans.
* It should be checked into source control and tracked carefully.
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`test/02-snapshot/bin/east/commands/migrate/withNotInitializedEnv.js TAP > output 1`] = `
Error: Migrations directory: [Migrations dir] doesn't exist. You should run \`init\` command to initialize migrations or change \`dir\` option.
[East source stack trace]
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict';

const tap = require('tap');
const expect = require('expect.js');
const testUtils = require('../../../../../../testUtils');

tap.mochaGlobals();

const describeTitle = 'bin/east migrate with not initialized env';

describe(describeTitle, () => {
let commandErr;
let testEnv;

before(() => {
return Promise.resolve()
.then(() => testUtils.createEnv({migratorParams: {init: false}}))
.then((createdTestEnv) => {
testEnv = createdTestEnv;
});
});

after(() => testUtils.destroyEnv(testEnv));

it('should be done without error', () => {
return Promise.resolve()
.then(() => {
const binPath = testUtils.getBinPath('east');

return testUtils.execAsync(
`"${binPath}" migrate`,
{cwd: testEnv.dir}
);
})
.then((commandResult) => {
throw new Error(
`Error expexted but result returned: ${commandResult.stdout}`
);
})
.catch((err) => {
expect(err).ok();
expect(err.code).equal(1);

commandErr = err;
});
});

it('output should match expected snapshot', () => {
const output = `${commandErr.stdout}\n${commandErr.stderr}`;

tap.matchSnapshot(
testUtils.cleanSnapshotData(output),
'output'
);
});
});

0 comments on commit fec452a

Please sign in to comment.