-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for migrate with not initialized env
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...snapshots/test-02-snapshot-bin-east-commands-migrate-withNotInitializedEnv.js-TAP.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
` |
56 changes: 56 additions & 0 deletions
56
test/02-snapshot/bin/east/commands/migrate/withNotInitializedEnv.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
); | ||
}); | ||
}); |