-
Notifications
You must be signed in to change notification settings - Fork 1
/
resultsShared.js
120 lines (106 loc) · 3.73 KB
/
resultsShared.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
class Result {
testStatus; // String: pass | fail | skip | error
responseStatus; // Integer
actual; // String
expected; // String
error; // Error
constructor(testsName, groupName, test) {
this.testsName = testsName;
this.groupName = groupName;
this.testName = test.name;
if (typeof test.expression !== 'string') {
this.invalid = test.expression.invalid;
this.expression = test.expression.text;
}
else {
this.invalid = 'false';
this.expression = test.expression;
}
if (test.output !== undefined) {
if (typeof test.output !== 'string') {
// TODO: Structure the result if it can be structured (i.e. is one of the expected types)
this.expected = test.output.text;
}
else {
this.expected = test.output;
}
}
else {
this.testStatus = 'skip';
}
}
}
async function generateEmptyResults(tests, quickTest) {
//const tests = loadTests.load();
// Set this to true to run only the first group of tests
//const quickTest = config.Debug.QuickTest
console.log('QuickTest: ' + quickTest)
// const onlyTestsName = "ValueLiteralsAndSelectors";
// const onlyGroupName = "Decimal";
// const onlyTestName = "DecimalNeg10Pow28ToZeroOneStepDecimalMinValue";
let results = [];
let groupResults = [];
for (const ts of tests) {
if (typeof onlyTestsName === 'undefined' || onlyTestsName === ts.name) {
console.log('Tests: ' + ts.name);
let groupTests = [];
for (const group of ts.group) {
if (typeof onlyGroupName === 'undefined' || onlyGroupName === group.name) {
console.log(' Group: ' + group.name);
let test = group.test;
if (test != undefined) {
for (const t of test) {
if (typeof onlyTestName === 'undefined' || onlyTestName === t.name) {
console.log(' Test: ' + t.name);
var r = new Result(ts.name, group.name, t);
results.push(r);
groupTests.push(r);
}
}
}
if (quickTest) {
break; // Only load 1 group for testing
}
}
}//push array for each test file
groupResults.push(groupTests);
if (quickTest) {
break; // Only load 1 test set for testing
}
}
}
return groupResults
}
function generateParametersResource(result, cqlEndpoint) {
let data = '';
// Check if the last part is $cql or $evaluate
if (cqlEndpoint === '$cql') {
data = {
"resourceType": "Parameters",
"parameter": [{
"name": "expression",
"valueString": result.expression
}]
};
} else if (cqlEndpoint === '$evaluate') {
data = {
"resourceType": "Parameters",
"parameter": [{
"name": "url",
"valueCanonical": "https://hl7.org/fhir/uv/cql/Library/" + result.testsName + "|1.0.000"
},
{
"name": "expression",
"valueString": "" + result.groupName + '.' + result.testName + ""
}
]
};
} else {
console.log('The URL does not end with $cql or $evaluate');
}
return data;
}
module.exports = {
generateEmptyResults,
generateParametersResource
}