forked from martysweet/cfn-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexTest.js
81 lines (61 loc) · 2.9 KB
/
indexTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const chai = require('chai');
const expect = chai.expect;
const assert = chai.assert;
describe('index', () => {
describe('CLI', () => {
it('no parameters', (done) => {
let exec = require('child_process').exec;
exec('node lib/index.js', function(error, stdout, stderr) {
expect(stderr).to.contain('no command given!');
done();
});
}).timeout(5000);;
it('missing file parameter', (done) => {
let exec = require('child_process').exec;
exec('node lib/index.js validate', function(error, stdout, stderr) {
expect(stderr).to.contain('missing required argument');
done();
});
}).timeout(5000);;
it('validate simple yaml', (done) => {
let exec = require('child_process').exec;
exec('node lib/index.js validate test/data/valid/yaml/issue-28-custom-resource.yaml', function(error, stdout, stderr) {
console.log(stderr);
console.log(stdout);
expect(stdout).to.contain('0 crit');
done();
});
}).timeout(5000);
it('validate parameter flag', (done) => {
let exec = require('child_process').exec;
exec('node lib/index.js validate test/data/valid/json/2.json --parameters InstanceType="t1.micro"', function(error, stdout, stderr) {
expect(stdout).to.contain('0 crit');
done();
});
}).timeout(5000);
it('validate pseudo flag', (done) => {
let exec = require('child_process').exec;
exec('node lib/index.js validate test/data/valid/yaml/pseudo-parameters.yaml ' +
'--pseudo AWS::Region=us-east-1,AWS::AccountId=000000000000', function(error, stdout, stderr) {
expect(stdout).to.contain('0 crit');
done();
});
}).timeout(5000);
it('validate pseudo + parameter flag', (done) => {
let exec = require('child_process').exec;
exec('node lib/index.js validate test/data/valid/yaml/pseudo-w-parameter.yaml ' +
'--parameters MyInput=abcd --pseudo AWS::Region=us-east-1', function(error, stdout, stderr) {
expect(stdout).to.contain('0 crit');
done();
});
}).timeout(5000);
it('invalid pseudo flag throws 2 critical error', (done) => {
let exec = require('child_process').exec;
exec('node lib/index.js validate test/data/valid/yaml/pseudo-parameters.yaml ' +
'--pseudo AWS::Region=us-east-1,Something=000000000000', function(error, stdout, stderr) {
expect(stdout).to.contain('2 crit');
done();
});
}).timeout(5000);
});
});