-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
31 lines (29 loc) · 1.05 KB
/
test.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
#!/usr/bin/env node
const child_process = require('child_process');
const spawnSync = child_process.spawnSync;
const seed = 'name:string,count:number,category:array(5)[number],data:object{field_string:string,field_number:number,field_array:array(1)[string],field_null:null,field_undefined:undefined,field_bool_true:bool,field_bool_false:bool!}';
test('-s array(5)[number]');
test('-s object{field_string:string,field_number:number,field_array:array(1)[string],field_null:null,field_undefined:undefined,field_bool_true:bool,field_bool_false:bool!}');
test('-p 4 -s ' + seed);
test('-p 4 -s ' + seed);
test('-p 4 -s ' + seed + ' -o ./mock.json ');
// Test function
function test(args, cb) {
let result = null;
console.log(`Test width ${args}`);
console.log();
console.log();
try {
result = spawnSync(
'node',
['./seed-mock.js'].concat((args || '').split(/\b\s+/))
).stdout.toString();
console.log(result);
} catch (err) {
console.error('ERROR ' + err);
}
console.log();
if (typeof cb === 'function'){
cb(args, result);
}
}