Skip to content

Commit

Permalink
update test scripts per changes in the semantic and model validator (A…
Browse files Browse the repository at this point in the history
  • Loading branch information
amarzavery authored and vishrutshah committed Mar 2, 2017
1 parent e4b285e commit dc4216e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
5 changes: 5 additions & 0 deletions test/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ var _ = require('lodash'),
describe('AutoRest Linter validation:', function () {
var autoRestLocation = './AutoRest.*/tools/AutoRest.exe';
let swaggersToProcess = utils.getFilesChangedInPR();
// Useful when debugging a test for a particular swagger.
// Just update the regex. That will return an array of filtered items.
// swaggersToProcess = swaggersToProcess.filter(function(item) {
// return (item.match(/.arm-containerregistry.*2017-03-01.*/ig) !== null);
// });
_(swaggersToProcess).each(function (swagger) {
it(swagger + ' should honor linter validation rules.', function (done) {
var cmd = utils.clrCmd(autoRestLocation + ' -CodeGenerator None -I ' + swagger);
Expand Down
10 changes: 8 additions & 2 deletions test/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ var _ = require('lodash'),

describe('Azure swagger model validation using x-ms-examples and examples in spec', function () {
let swaggersToProcess = utils.getFilesChangedInPR();
// Useful when debugging a test for a particular swagger.
// Just update the regex. That will return an array of filtered items.
// swaggersToProcess = swaggersToProcess.filter(function(item) {
// return (item.match(/.arm-containerregistry.*2017-03-01.*/ig) !== null);
// });
_(swaggersToProcess).each(function (swagger) {
it(swagger + ' should have valid examples.', function (done) {
oav.validateExamples(swagger, null, false, 'error').then(function (validationResult) {
oav.validateExamples(swagger, null, 'error').then(function (validationResult) {
//console.dir(validationResult, {depth: null, colors: true});
done(assert(validationResult.validityStatus === true, `swagger "${swagger}" contains model validation errors.`));
}).catch(function (err) {
console.log(err);
console.dir(err, {depth: null, colors: true});
done(err);
});
});
Expand Down
14 changes: 11 additions & 3 deletions test/semantic.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ var _ = require('lodash'),

describe('Azure swagger semantic validation:', function () {
let swaggersToProcess = utils.getFilesChangedInPR();
// Useful when debugging a test for a particular swagger.
// Just update the regex. That will return an array of filtered items.
// swaggersToProcess = swaggersToProcess.filter(function(item) {
// return (item.match(/.arm-containerregistry.*2017-03-01.*/ig) !== null);
// });

_(swaggersToProcess).each(function (swagger) {
it(swagger + ' should be semantically valid.', function (done) {
oav.validateSpec(swagger, false, 'error').then(function (validationResult) {
done(assert(validationResult.errors && validationResult.errors.length === 0, `swagger "${swagger}" contains semantic validation errors.`));
oav.validateSpec(swagger, 'error').then(function (validationResult) {
//console.dir(validationResult, {depth: null, colors: true});
done(assert(validationResult.validateSpec && validationResult.validateSpec.errors && validationResult.validateSpec.errors.length === 0,
`swagger "${swagger}" contains semantic validation errors.`));
}).catch(function (err) {
console.log(err);
console.dir(err, {depth: null, colors: true});
done(err);
});
});
Expand Down

0 comments on commit dc4216e

Please sign in to comment.