Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
test: update tests to reflect the --level and --silent removal
Browse files Browse the repository at this point in the history
  • Loading branch information
honzajavorek committed Jan 23, 2019
1 parent d1b6ebb commit 3144251
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 46 deletions.
6 changes: 4 additions & 2 deletions test/integration/cli/hookfiles-cli-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ describe('CLI', () => {
});
});

describe('when setting the log output level with --level', () => {
describe('when setting the log output level with --loglevel', () => {
let runtimeInfo;

before((done) => {
Expand All @@ -543,7 +543,7 @@ describe('CLI', () => {
const args = [
'./test/fixtures/single-get.apib',
`http://127.0.0.1:${DEFAULT_SERVER_PORT}`,
'--level=error',
'--loglevel=error',
'--color=false',
];
runCLIWithServer(args, app, (err, info) => {
Expand Down Expand Up @@ -734,6 +734,7 @@ describe('CLI', () => {
'./test/fixtures/multifile/*.apib',
`http://127.0.0.1:${DEFAULT_SERVER_PORT}`,
'--names',
'--loglevel=debug',
];
runCLI(args, (err, info) => {
cliInfo = info;
Expand Down Expand Up @@ -800,6 +801,7 @@ describe('CLI', () => {
'./test/fixtures/multiple-examples.apib',
`http://127.0.0.1:${DEFAULT_SERVER_PORT}`,
'--path=./test/fixtures/multifile/*.apib',
'--loglevel=debug',
'--names',
];
runCLI(args, (err, info) => {
Expand Down
1 change: 0 additions & 1 deletion test/integration/cli/reporters-cli-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ describe('CLI - Reporters', () => {
});

it('hooks.log should print also to console', () => {
// Because --level=info is lower than --level=hook
assert.include(cliInfo.output, 'using hooks.log to debug');
});
it('hooks.log should use toString on objects', () => assert.include(cliInfo.output, 'Error object!'));
Expand Down
13 changes: 8 additions & 5 deletions test/integration/cli/server-process-cli-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe('CLI - Server Process', () => {
`http://127.0.0.1:${DEFAULT_SERVER_PORT}`,
`--server=node ./test/fixtures/scripts/dummy-server.js ${DEFAULT_SERVER_PORT}`,
'--server-wait=1',
'--loglevel=debug',
];

beforeEach(done => runCLI(args, (err, info) => {
Expand All @@ -88,6 +89,7 @@ describe('CLI - Server Process', () => {
`http://127.0.0.1:${DEFAULT_SERVER_PORT}`,
'--server=/foo/bar/baz',
'--server-wait=1',
'--loglevel=debug',
];

beforeEach(done => runCLI(args, (err, info) => {
Expand All @@ -101,25 +103,25 @@ describe('CLI - Server Process', () => {
});

for (const scenario of [{
description: 'When crashes before requests',
description: 'when crashes before requests',
apiDescriptionDocument: './test/fixtures/single-get.apib',
server: 'node test/fixtures/scripts/exit-3.js',
expectServerBoot: false,
},
{
description: 'When crashes during requests',
description: 'when crashes during requests',
apiDescriptionDocument: './test/fixtures/apiary.apib',
server: `node test/fixtures/scripts/dummy-server-crash.js ${DEFAULT_SERVER_PORT}`,
expectServerBoot: true,
},
{
description: 'When killed before requests',
description: 'when killed before requests',
apiDescriptionDocument: './test/fixtures/single-get.apib',
server: 'node test/fixtures/scripts/kill-self.js',
expectServerBoot: false,
},
{
description: 'When killed during requests',
description: 'when killed during requests',
apiDescriptionDocument: './test/fixtures/apiary.apib',
server: `node test/fixtures/scripts/dummy-server-kill.js ${DEFAULT_SERVER_PORT}`,
expectServerBoot: true,
Expand All @@ -132,6 +134,7 @@ describe('CLI - Server Process', () => {
`http://127.0.0.1:${DEFAULT_SERVER_PORT}`,
`--server=${scenario.server}`,
'--server-wait=1',
'--loglevel=debug',
];

beforeEach(done => runCLI(args, (err, info) => {
Expand Down Expand Up @@ -159,7 +162,7 @@ describe('CLI - Server Process', () => {
`http://127.0.0.1:${DEFAULT_SERVER_PORT}`,
`--server=node test/fixtures/scripts/dummy-server-ignore-term.js ${DEFAULT_SERVER_PORT}`,
'--server-wait=1',
'--level=verbose',
'--loglevel=debug',
];

beforeEach(done => runCLI(args, (err, info) => {
Expand Down
8 changes: 4 additions & 4 deletions test/integration/dredd-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function execCommand(options = {}, cb) {
exitStatus = null;
let finished = false;
if (!options.server) { options.server = `http://127.0.0.1:${PORT}`; }
if (!options.level) { options.level = 'info'; }
if (!options.loglevel) { options.loglevel = 'warning'; }
new Dredd(options).run((error, stats = {}) => {
if (!finished) {
finished = true;
Expand Down Expand Up @@ -112,7 +112,7 @@ describe('Dredd class Integration', () => {
options: {
path: ['./test/fixtures/single-get.apib'],
reporter: ['apiary'],
level: 'verbose',
loglevel: 'debug',
},
custom: {
apiaryApiUrl: `http://127.0.0.1:${PORT + 1}`,
Expand Down Expand Up @@ -224,7 +224,7 @@ describe('Dredd class Integration', () => {
options: {
path: ['./test/fixtures/single-get.apib'],
reporter: ['apiary'],
level: 'verbose',
loglevel: 'debug',
},
custom: {
apiaryReporterEnv: {
Expand Down Expand Up @@ -281,7 +281,7 @@ describe('Dredd class Integration', () => {
options: {
path: ['./test/fixtures/single-get.apib'],
reporter: ['apiary'],
level: 'verbose',
loglevel: 'debug',
},
custom: {
apiaryReporterEnv: {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function runDredd(dredd, serverPort, callback) {
if (dredd.configuration.server == null) { dredd.configuration.server = `http://127.0.0.1:${serverPort}`; }

if (dredd.configuration.options == null) { dredd.configuration.options = {}; }
if (dredd.configuration.options.level == null) { dredd.configuration.options.level = 'silly'; }
if (dredd.configuration.options.loglevel == null) { dredd.configuration.options.loglevel = 'debug'; }

let stats;

Expand Down
5 changes: 3 additions & 2 deletions test/integration/proxy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ const REGULAR_HTTP_METHODS = ['GET', 'POST', 'PUT', 'DELETE'];
function createAndRunDredd(configuration, done) {
if (!configuration.options) { configuration.options = {}; }
configuration.options.color = false;
configuration.options.silent = true;
configuration.options.level = 'silly';
configuration.options.loglevel = 'debug';

let dredd;
recordLogging((next) => {
Expand Down Expand Up @@ -172,6 +171,7 @@ ${protocol}_proxy=${PROXY_URL}\
describe('Requesting Server Under Test', () => test({
protocol,
configureDredd(configuration) {
configuration.loglevel = 'debug';
configuration.server = serverUrl;
configuration.options.path = './test/fixtures/single-get.apib';
},
Expand Down Expand Up @@ -230,6 +230,7 @@ http_proxy=${PROXY_URL}, no_proxy=${SERVER_HOST}\
describe('Requesting Server Under Test', () => test({
protocol: 'http',
configureDredd(configuration) {
configuration.loglevel = 'debug';
configuration.server = serverUrl;
configuration.options.path = './test/fixtures/single-get.apib';
},
Expand Down
3 changes: 1 addition & 2 deletions test/unit/CLI-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,8 @@ describe('CLI class', () => {
details: false,
method: [],
color: true,
level: 'info',
loglevel: 'warning',
timestamp: false,
silent: false,
path: [],
$0: 'node ./bin/dredd',
}));
Expand Down
21 changes: 7 additions & 14 deletions test/unit/Dredd-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe('Dredd class', () => {
configuration = {
server: 'http://127.0.0.1:3000/',
options: {
silent: true,
method: 'get',
header: 'Accept:application/json',
user: 'bob:test',
Expand All @@ -41,7 +40,7 @@ describe('Dredd class', () => {

it('should copy configuration on creation', () => {
dredd = new Dredd(configuration);
assert.isOk(dredd.configuration.options.silent);
assert.isOk(dredd.configuration.options.sorted);
assert.notOk(dredd.configuration.options['dry-run']);
});

Expand Down Expand Up @@ -91,7 +90,7 @@ describe('Dredd class', () => {
configuration = {
server: 'http://127.0.0.1:3000/',
options: {
silent: true,

path: ['./test/fixtures/multifile/*.apib', './test/fixtures/multifile/*.apib'],
},
};
Expand Down Expand Up @@ -141,7 +140,7 @@ describe('Dredd class', () => {
configuration = {
server: 'http://127.0.0.1:3000/',
options: {
silent: true,

path: ['./test/fixtures/multifile/*.balony', './test/fixtures/multifile/*.apib'],
},
};
Expand All @@ -164,7 +163,7 @@ describe('Dredd class', () => {
configuration = {
server: 'http://127.0.0.1:3000/',
options: {
silent: true,

path: ['./test/fixtures/multifile/*.balony'],
},
};
Expand All @@ -187,7 +186,7 @@ describe('Dredd class', () => {
configuration = {
server: 'http://127.0.0.1:3000/',
options: {
silent: true,

},
data: {
testingDirectObject: {
Expand Down Expand Up @@ -279,7 +278,7 @@ GET /url
configuration = {
server: 'http://127.0.0.1:3000/',
options: {
silent: true,

path: ['http://some.path.to/file.apib', 'https://another.path.to/apiary.apib', './test/fixtures/multifile/*.apib'],
},
};
Expand Down Expand Up @@ -411,7 +410,6 @@ GET /url
configuration = {
url: 'http://127.0.0.1:3000/',
options: {
silent: true,
path: ['./test/fixtures/error-blueprint.apib'],
},
};
Expand All @@ -438,7 +436,6 @@ GET /url
configuration = {
url: 'http://127.0.0.1:3000/',
options: {
silent: true,
path: ['./test/fixtures/warning-ambiguous.apib'],
},
};
Expand Down Expand Up @@ -471,7 +468,6 @@ GET /url
configuration = {
url: 'http://127.0.0.1:3000/',
options: {
silent: true,
path: ['./balony/path.apib'],
},
};
Expand All @@ -497,7 +493,6 @@ GET /url
configuration = {
server: 'http://127.0.0.1:3000/',
options: {
silent: true,
path: ['./test/fixtures/error-uri-template.apib'],
},
};
Expand All @@ -524,7 +519,6 @@ GET /url
configuration = {
server: 'http://127.0.0.1:3000/',
options: {
silent: true,
path: ['./test/fixtures/warning-ambiguous.apib'],
},
};
Expand Down Expand Up @@ -559,7 +553,6 @@ GET /url
configuration = {
server: 'http://127.0.0.1:3000/',
options: {
silent: true,
path: ['./test/fixtures/apiary.apib'],
},
};
Expand All @@ -585,7 +578,7 @@ GET /url
configuration = {
server: 'http://127.0.0.1:3000/',
options: {
silent: true,

reporter: ['apiary'],
path: ['./test/fixtures/apiary.apib'],
custom: {
Expand Down
9 changes: 3 additions & 6 deletions test/unit/configUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ const argvData = {
m: [],
color: true,
c: true,
level: 'info',
l: 'info',
loglevel: 'warning',
l: 'warning',
timestamp: false,
t: false,
silent: false,
q: false,
path: [],
p: [],
$0: 'node ./bin/dredd',
Expand Down Expand Up @@ -163,9 +161,8 @@ inline-errors: false
details: false
method: []
color: true
level: info
loglevel: info
timestamp: false
silent: false
path: []
blueprint: blueprint
endpoint: endpoint\
Expand Down
8 changes: 4 additions & 4 deletions test/unit/configuration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ describe('configuration.applyLoggingOptions()', () => {
it('applies logging options', () => {
config = configuration.applyLoggingOptions({
color: 'true',
level: 'debug',
loglevel: 'debug',
});

assert.propertyVal(config, 'color', true);
assert.equal(logger.transports.console.colorize, true);

assert.propertyVal(config, 'level', 'debug');
assert.propertyVal(config, 'loglevel', 'debug');
assert.equal(logger.transports.console.level, 'debug');
});

Expand All @@ -46,14 +46,14 @@ describe('configuration.applyConfiguration()', () => {
config = configuration.applyConfiguration({
options: {
color: 'true',
level: 'debug',
loglevel: 'debug',
},
});

assert.nestedPropertyVal(config, 'options.color', true);
assert.equal(logger.transports.console.colorize, true);

assert.nestedPropertyVal(config, 'options.level', 'debug');
assert.nestedPropertyVal(config, 'options.loglevel', 'debug');
assert.equal(logger.transports.console.level, 'debug');
});
});
9 changes: 4 additions & 5 deletions test/unit/configureReporters-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe('configureReporters(config, stats, tests, onSaveCallback)', () => {
options: {
reporter: [],
output: [],
silent: false,
'inline-errors': false,
},
};
Expand All @@ -71,15 +70,15 @@ describe('configureReporters(config, stats, tests, onSaveCallback)', () => {
});

describe('when silent', () => {
before(() => configuration.options.silent = true);
before(() => configuration.options.loglevel = 'silent');

after(() => configuration.options.silent = false);
after(() => configuration.options.loglevel = 'silent');

beforeEach(() => resetStubs());

it('should not add any reporters', (done) => {
it('should still add reporters', (done) => {
configureReporters(configuration, {}, {}, null);
assert.notOk(CliReporterStub.called);
assert.ok(CliReporterStub.called);
return done();
});
});
Expand Down

0 comments on commit 3144251

Please sign in to comment.