ondc-code-generator 0.7.5 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -49,11 +49,11 @@ export class GoGenerator extends CodeGenerator {
|
|
|
49
49
|
validationCode: await this.createValidationLogicCode(testObject),
|
|
50
50
|
successCode: testObject[TestObjectSyntax.SuccessCode] ?? 200,
|
|
51
51
|
errorCode: testObject[TestObjectSyntax.ErrorCode] ?? 30000,
|
|
52
|
-
testName: testObject[TestObjectSyntax.Name],
|
|
52
|
+
testName: stringToCaps(testObject[TestObjectSyntax.Name]),
|
|
53
53
|
TEST_OBJECT: `${JSON.stringify(testObject)}`,
|
|
54
54
|
};
|
|
55
55
|
return {
|
|
56
|
-
funcName: testObject[TestObjectSyntax.Name],
|
|
56
|
+
funcName: stringToCaps(testObject[TestObjectSyntax.Name]),
|
|
57
57
|
code: Mustache.render(template, view),
|
|
58
58
|
};
|
|
59
59
|
};
|
|
@@ -274,8 +274,6 @@ ${importList.map((imp) => `\t${imp}`).join("\n")}
|
|
|
274
274
|
for (const name of varNames) {
|
|
275
275
|
const value = testObject[name];
|
|
276
276
|
if (!elementsList.includes(name)) {
|
|
277
|
-
console.log(`Variable ${name} not used in return or continue statements, skipping generation.: \n ${returnStatement} \n ${continueStatement}`);
|
|
278
|
-
console.log(elementsList);
|
|
279
277
|
continue;
|
|
280
278
|
}
|
|
281
279
|
let final = "";
|
|
@@ -52,9 +52,6 @@ export class ScopeValidator extends TestObjectValidator {
|
|
|
52
52
|
if (!isValidJsonPath(path)) {
|
|
53
53
|
throw new Error(`${TestObjectSyntax.Scope} should be a valid json path at path ${this.validationPath}`);
|
|
54
54
|
}
|
|
55
|
-
if (!path.startsWith(`$.`)) {
|
|
56
|
-
throw new Error(`${TestObjectSyntax.Scope} json path should start with $. at ${this.validationPath}`);
|
|
57
|
-
}
|
|
58
55
|
if (this.minimal)
|
|
59
56
|
return;
|
|
60
57
|
if (this.impossiblePaths.includes(replaceBracketsWithAsteriskNested(path))) {
|
|
@@ -114,9 +111,6 @@ export class VariableValidator extends TestObjectValidator {
|
|
|
114
111
|
if (!isValidJsonPath(value)) {
|
|
115
112
|
throw new Error(`Variable: ${key} should be a valid jsonPath at ${this.validationPath}`);
|
|
116
113
|
}
|
|
117
|
-
if (!value.startsWith(`$.`)) {
|
|
118
|
-
throw new Error(`Variable: ${key} should start with $. at ${this.validationPath}`);
|
|
119
|
-
}
|
|
120
114
|
if (value.startsWith(`$.${ExternalDataSyntax}`)) {
|
|
121
115
|
this.validateExternalData(value, this.externalVariables);
|
|
122
116
|
return;
|
|
@@ -124,7 +118,7 @@ export class VariableValidator extends TestObjectValidator {
|
|
|
124
118
|
let path = value;
|
|
125
119
|
if (this.targetObject[TestObjectSyntax.Scope]) {
|
|
126
120
|
const scope = this.targetObject[TestObjectSyntax.Scope];
|
|
127
|
-
const pathWithoutDollar = path
|
|
121
|
+
const pathWithoutDollar = cleanseDollarDot(path);
|
|
128
122
|
path = `${scope}.${pathWithoutDollar}`;
|
|
129
123
|
}
|
|
130
124
|
const replaced = replaceBracketsWithAsteriskNested(path);
|
|
@@ -208,3 +202,12 @@ export class ReturnValidator extends TestObjectValidator {
|
|
|
208
202
|
this.dependencies = dependencies;
|
|
209
203
|
}
|
|
210
204
|
}
|
|
205
|
+
function cleanseDollarDot(path) {
|
|
206
|
+
if (path.startsWith(`$.`)) {
|
|
207
|
+
return path.slice(2);
|
|
208
|
+
}
|
|
209
|
+
else if (path.startsWith(`$`)) {
|
|
210
|
+
return path.slice(1);
|
|
211
|
+
}
|
|
212
|
+
return path;
|
|
213
|
+
}
|