Skip to content

Commit

Permalink
add tests for list with valid and unrecognized status
Browse files Browse the repository at this point in the history
  • Loading branch information
okv committed Sep 3, 2019
1 parent 198e1c8 commit fffa9ab
Show file tree
Hide file tree
Showing 4 changed files with 139 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/list/withStatus.js TAP > output 1`] = `
new migrations:
1_someMigrationName
2_anotherMigrationName
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* 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/list/withUnrecognizedStatus.js TAP > output 1`] = `
Unrecognized status "unrecognizedStatus"
`
54 changes: 54 additions & 0 deletions test/02-snapshot/bin/east/commands/list/withStatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use strict';

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

tap.mochaGlobals();

const binPath = testUtils.getBinPath('east');
const describeTitle = 'bin/east list with status';

describe(describeTitle, () => {
let commandResult;
let migrator;

before(() => {
return Promise.resolve()
.then(() => testUtils.createMigrator({init: true}))
.then((createdMigrator) => {
migrator = createdMigrator;

return testUtils.createMigrations({
migrator,
baseNames: ['someMigrationName', 'anotherMigrationName']
});
});
});

after(() => testUtils.destroyMigrator({migrator}));

it('should be done without error', () => {
const cwd = testUtils.getTestDirPath();

return Promise.resolve()
.then(() => {
return testUtils.execAsync(
`"${binPath}" list new`,
{cwd}
);
})
.then((result) => {
expect(result.stderr).not.ok();

commandResult = result;
});
});

it('stdout should match expected snapshot', () => {
tap.matchSnapshot(
testUtils.cleanSnapshotData(commandResult.stdout),
'output'
);
});
});
61 changes: 61 additions & 0 deletions test/02-snapshot/bin/east/commands/list/withUnrecognizedStatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'use strict';

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

tap.mochaGlobals();

const binPath = testUtils.getBinPath('east');
const describeTitle = 'bin/east list with unrecognized status';

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

before(() => {
return Promise.resolve()
.then(() => testUtils.createMigrator({init: true}))
.then((createdMigrator) => {
migrator = createdMigrator;

return testUtils.createMigrations({
migrator,
baseNames: ['someMigrationName', 'anotherMigrationName']
});
});
});

after(() => testUtils.destroyMigrator({migrator}));

it('should be done without error', () => {
const cwd = testUtils.getTestDirPath();

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

commandErr = err;
});
});

it('stderr should match expected snapshot', () => {
tap.matchSnapshot(
testUtils.cleanSnapshotData(commandErr.stderr),
'output'
);
});
});

0 comments on commit fffa9ab

Please sign in to comment.