Skip to content

Commit

Permalink
feat(run parameters): Don't include WAFFLE_SERVER_TAG validation in…
Browse files Browse the repository at this point in the history
… normal validation

Closes #533
  • Loading branch information
buchslava committed Nov 28, 2018
1 parent afc84d3 commit 2227230
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Options:
--summary Show summary data regarding the issues after validation
--datapointless Forget about datapoint validation
--hidden Allow hidden folders validation
--ws Apply Waffle Server specific rules
--include-tags Process only issues by selected tags
--exclude-tags Process all tags except selected
--include-rules Process only issues by selected rules
Expand All @@ -35,7 +36,8 @@ Examples:
validate-ddf ../ddf-example -i --translations --content rewrite "translations", "resources" and "ddfSchema" sections in datapackage.json
validate-ddf ../ddf-example -j fix JSONs for this DDF dataset
validate-ddf --rules print information regarding supported rules
validate-ddf ../ddf-example --summary Show summary data after validation in case of errors are found
validate-ddf ../ddf-example --summary
validate-ddf ../ddf-example --ws apply Waffle Server specific rules. See WAFFLE_SERVER_TAG tag based rules in the rules list (--rules flag)')Show summary data after validation in case of errors are found
validate-ddf ../ddf-example --multithread validate datapoints for `ddf-example` in separate threads
validate-ddf ../ddf-example --multithread --use-all-cpu use all CPU during validation via multithread mode
validate-ddf ../ddf-example --datapointless forget about datapoint validation
Expand Down
7 changes: 7 additions & 0 deletions src/utils/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const argv = yargs
.example(`${myName} ../ddf-example -i --translations --content`, 'rewrite "translations", "resources" and "ddfSchema" sections in datapackage.json')
.example(`${myName} ../ddf-example -j`, 'fix JSONs for this DDF dataset')
.example(`${myName} --rules`, 'print information regarding supported rules')
.example(`${myName} ../ddf-example --ws`, 'apply Waffle Server specific rules. See WAFFLE_SERVER_TAG tag based rules in the rules list (--rules flag)')
.example(`${myName} ../ddf-example --multithread`,
'validate datapoints for `ddf-example` in separate threads')
.example(`${myName} ../ddf-example --multithread --use-all-cpu`,
Expand Down Expand Up @@ -43,6 +44,7 @@ const argv = yargs
.describe('datapointless', 'forget about datapoint validation')
.describe('silent', `don't show progress of validation and print issues to the screen`)
.describe('hidden', 'allow hidden folders validation')
.describe('ws', 'apply Waffle Server specific rules')
.describe('include-tags', 'Process only issues by selected tags')
.describe('exclude-tags', 'Process all tags except selected')
.describe('include-rules', 'Process only issues by selected rules')
Expand Down Expand Up @@ -76,6 +78,7 @@ export const getSettings = () => {
settings.isPrintRules = !!argv.rules;
settings.isCheckHidden = !!argv.hidden;
settings.isMultithread = !!argv.multithread;
settings.isWaffleServer = !!argv.ws;
settings.useAllCpu = !!argv['use-all-cpu'];
settings.compressDatapackage = argv['compress-datapackage'];
};
Expand All @@ -84,6 +87,10 @@ export const getSettings = () => {

options.forEach(option => {
settings[camelCase(option)] = argv[option];

if (option === 'exclude-tags' && !settings.isWaffleServer) {
settings[camelCase(option)] += ' WAFFLE_SERVER_TAG';
}
});

settings.excludeDirs = getExcludedDirs(settings);
Expand Down
40 changes: 40 additions & 0 deletions test/e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import * as chai from 'chai';
import { head } from 'lodash';
import { exec } from 'child_process';

const expect = chai.expect;

function execute(command, callback){
exec(command, function(error, stdout, stderr) {
callback(error, stdout, stderr);
});
}

describe('e2e', () => {
it('an issue should be found when "ws" flag is ON and DS contains WS based issue', done => {
execute('./src/cli.js ./test/fixtures/rules-cases/entity-value-as-entity-name --silent --ws', (error, stdout, stderr) => {
expect(!!error).to.be.true;
expect(error.code).to.be.equal(1);
expect(!!stdout).to.be.true;

const issues = JSON.parse(stdout);
const issue: {id: string} = <{id: string}>head(issues);

expect(issues.length).to.be.equals(1);
expect(issue.id).to.be.equals('ENTITY_VALUE_AS_ENTITY_NAME');
expect(!!stderr).to.be.false;

done();
});
});

it('any issue should NOT be found when "ws" flag is OFF and DS contains WS based issue', done => {
execute('./src/cli.js ./test/fixtures/rules-cases/entity-value-as-entity-name --silent', (error, stdout, stderr) => {
expect(!!error).to.be.false;
expect(!!stdout).to.be.false;
expect(!!stderr).to.be.false;

done();
});
});
});

0 comments on commit 2227230

Please sign in to comment.