@sasjs/cli 3.12.2 → 3.12.5
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.
- package/build/commands/add/spec/addTarget.spec.js +10 -8
- package/build/commands/build/build.js +18 -5
- package/build/commands/deploy/deploy.js +19 -18
- package/build/commands/deploy/spec/cbd.spec.js +30 -27
- package/build/commands/shared/deployToSasViyaWithServicePack.d.ts +2 -3
- package/build/commands/shared/deployToSasViyaWithServicePack.js +2 -2
- package/build/commands/testing/internal/saveOutput.d.ts +2 -2
- package/build/commands/testing/spec/mockedAdapter/testResponses.js +10 -0
- package/build/commands/testing/spec/testing.spec.js +23 -0
- package/build/commands/testing/test.js +23 -6
- package/build/types/index.d.ts +1 -2
- package/build/types/testing.d.ts +8 -0
- package/build/utils/test.js +3 -0
- package/package.json +3 -3
- package/build/types/servicePack.d.ts +0 -9
- package/build/types/servicePack.js +0 -2
|
@@ -82,6 +82,7 @@ describe('addTarget', function () {
|
|
|
82
82
|
var viyaTargetName = "test-viya-".concat((0, utils_1.generateTimestamp)());
|
|
83
83
|
var sas9TargetName = "test-sas9-".concat((0, utils_1.generateTimestamp)());
|
|
84
84
|
var sasjsTargetName = "test-server-".concat((0, utils_1.generateTimestamp)());
|
|
85
|
+
var serverUrl = process.env.VIYA_SERVER_URL || '';
|
|
85
86
|
var globalTestTarget;
|
|
86
87
|
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
88
|
return __generator(this, function (_a) {
|
|
@@ -138,7 +139,7 @@ describe('addTarget', function () {
|
|
|
138
139
|
serverType: utils_1.ServerType.SasViya,
|
|
139
140
|
name: viyaTargetName,
|
|
140
141
|
appLoc: '/Public/app',
|
|
141
|
-
serverUrl:
|
|
142
|
+
serverUrl: serverUrl,
|
|
142
143
|
existingTarget: {}
|
|
143
144
|
};
|
|
144
145
|
jest
|
|
@@ -175,7 +176,7 @@ describe('addTarget', function () {
|
|
|
175
176
|
serverType: utils_1.ServerType.Sasjs,
|
|
176
177
|
name: sasjsTargetName,
|
|
177
178
|
appLoc: '/Public/app',
|
|
178
|
-
serverUrl:
|
|
179
|
+
serverUrl: serverUrl,
|
|
179
180
|
existingTarget: {}
|
|
180
181
|
};
|
|
181
182
|
jest
|
|
@@ -211,7 +212,7 @@ describe('addTarget', function () {
|
|
|
211
212
|
serverType: utils_1.ServerType.Sas9,
|
|
212
213
|
name: sas9TargetName,
|
|
213
214
|
appLoc: '/Public/app',
|
|
214
|
-
serverUrl:
|
|
215
|
+
serverUrl: serverUrl,
|
|
215
216
|
existingTarget: {}
|
|
216
217
|
};
|
|
217
218
|
jest
|
|
@@ -248,7 +249,7 @@ describe('addTarget', function () {
|
|
|
248
249
|
serverType: utils_1.ServerType.SasViya,
|
|
249
250
|
name: viyaTargetName,
|
|
250
251
|
appLoc: '/Public/app',
|
|
251
|
-
serverUrl:
|
|
252
|
+
serverUrl: serverUrl,
|
|
252
253
|
existingTarget: {}
|
|
253
254
|
};
|
|
254
255
|
jest
|
|
@@ -285,12 +286,13 @@ describe('addTarget', function () {
|
|
|
285
286
|
case 1:
|
|
286
287
|
config = _a.sent();
|
|
287
288
|
targetJson = (config.targets || []).find(function (t) { return t.name === 'viya'; });
|
|
289
|
+
targetJson.streamConfig.streamWeb = false;
|
|
288
290
|
commonFields = {
|
|
289
291
|
scope: targetScope_1.TargetScope.Local,
|
|
290
292
|
serverType: utils_1.ServerType.SasViya,
|
|
291
293
|
name: 'viya',
|
|
292
294
|
appLoc: '/Public/app/new/location',
|
|
293
|
-
serverUrl:
|
|
295
|
+
serverUrl: serverUrl,
|
|
294
296
|
existingTarget: targetJson
|
|
295
297
|
};
|
|
296
298
|
jest
|
|
@@ -332,7 +334,7 @@ describe('addTarget', function () {
|
|
|
332
334
|
serverType: utils_1.ServerType.Sas9,
|
|
333
335
|
name: 'sas9',
|
|
334
336
|
appLoc: '/Public/app/new/location/2',
|
|
335
|
-
serverUrl:
|
|
337
|
+
serverUrl: serverUrl,
|
|
336
338
|
existingTarget: target
|
|
337
339
|
};
|
|
338
340
|
jest
|
|
@@ -374,7 +376,7 @@ describe('addTarget', function () {
|
|
|
374
376
|
serverType: utils_1.ServerType.Sasjs,
|
|
375
377
|
name: 'server',
|
|
376
378
|
appLoc: '/Public/app/new/location/2',
|
|
377
|
-
serverUrl:
|
|
379
|
+
serverUrl: serverUrl,
|
|
378
380
|
existingTarget: targetJson
|
|
379
381
|
};
|
|
380
382
|
jest
|
|
@@ -410,7 +412,7 @@ describe('addTarget', function () {
|
|
|
410
412
|
serverType: globalTestTarget.serverType,
|
|
411
413
|
name: globalTestTarget.name,
|
|
412
414
|
appLoc: '/Public/app/new/location/3',
|
|
413
|
-
serverUrl:
|
|
415
|
+
serverUrl: serverUrl,
|
|
414
416
|
existingTarget: globalTestTarget
|
|
415
417
|
};
|
|
416
418
|
jest
|
|
@@ -96,6 +96,7 @@ var config_1 = require("../../utils/config");
|
|
|
96
96
|
var compile_1 = require("../compile/compile");
|
|
97
97
|
var config_2 = require("./internal/config");
|
|
98
98
|
var getLaunchPageCode_1 = require("./internal/getLaunchPageCode");
|
|
99
|
+
var types_1 = require("@sasjs/utils/types");
|
|
99
100
|
function build(target) {
|
|
100
101
|
return __awaiter(this, void 0, void 0, function () {
|
|
101
102
|
return __generator(this, function (_a) {
|
|
@@ -115,7 +116,7 @@ exports.build = build;
|
|
|
115
116
|
function createFinalSasFiles(target) {
|
|
116
117
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
117
118
|
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
-
var streamConfig, streamWeb, buildConfig, serverType, name, macroFolders, buildOutputFileName, buildDestinationFolder, finalSasFileContent, finalFilePath, finalFilePathJSON, buildInfo, buildInit, buildTerm, macroCorePath, dependencyFilePaths, dependenciesContent, _h, folderContent, folderContentJSON;
|
|
119
|
+
var streamConfig, streamWeb, buildConfig, serverType, name, macroFolders, buildOutputFileName, buildDestinationFolder, finalSasFileContent, finalFilePath, finalFilePathJSON, buildInfo, buildInit, buildTerm, macroCorePath, dependencyFilePaths, dependenciesContent, _h, folderContent, folderContentJSON, servicePackSASjs, servicePack;
|
|
119
120
|
return __generator(this, function (_j) {
|
|
120
121
|
switch (_j.label) {
|
|
121
122
|
case 0:
|
|
@@ -154,6 +155,10 @@ function createFinalSasFiles(target) {
|
|
|
154
155
|
return [4 /*yield*/, getFolderContent(serverType)];
|
|
155
156
|
case 8:
|
|
156
157
|
_h = _j.sent(), folderContent = _h.folderContent, folderContentJSON = _h.folderContentJSON;
|
|
158
|
+
servicePackSASjs = {
|
|
159
|
+
appLoc: target.appLoc,
|
|
160
|
+
fileTree: folderContentJSON
|
|
161
|
+
};
|
|
157
162
|
finalSasFileContent += "\n".concat(folderContent);
|
|
158
163
|
finalSasFileContent += "\n".concat(buildTerm);
|
|
159
164
|
if (streamWeb) {
|
|
@@ -161,6 +166,11 @@ function createFinalSasFiles(target) {
|
|
|
161
166
|
target.serverType === utils_1.ServerType.Sas9) {
|
|
162
167
|
finalSasFileContent += (0, getLaunchPageCode_1.getLaunchPageCode)(target.serverType, streamConfig.streamServiceName);
|
|
163
168
|
}
|
|
169
|
+
else if (target.serverType === utils_1.ServerType.Sasjs) {
|
|
170
|
+
servicePackSASjs.streamLogo = streamConfig.streamLogo;
|
|
171
|
+
servicePackSASjs.streamServiceName = streamConfig.streamServiceName;
|
|
172
|
+
servicePackSASjs.streamWebFolder = streamConfig.streamWebFolder;
|
|
173
|
+
}
|
|
164
174
|
}
|
|
165
175
|
finalSasFileContent = (0, utils_2.removeComments)(finalSasFileContent);
|
|
166
176
|
(_d = process.logger) === null || _d === void 0 ? void 0 : _d.debug("Creating file ".concat(finalFilePath, " ."));
|
|
@@ -169,7 +179,10 @@ function createFinalSasFiles(target) {
|
|
|
169
179
|
_j.sent();
|
|
170
180
|
(_e = process.logger) === null || _e === void 0 ? void 0 : _e.success("File ".concat(finalFilePath, " has been created."));
|
|
171
181
|
(_f = process.logger) === null || _f === void 0 ? void 0 : _f.debug("Creating file ".concat(finalFilePathJSON, " ."));
|
|
172
|
-
|
|
182
|
+
servicePack = target.serverType === utils_1.ServerType.Sasjs
|
|
183
|
+
? servicePackSASjs
|
|
184
|
+
: folderContentJSON;
|
|
185
|
+
return [4 /*yield*/, (0, utils_1.createFile)(finalFilePathJSON, JSON.stringify(servicePack, null, 1))];
|
|
173
186
|
case 10:
|
|
174
187
|
_j.sent();
|
|
175
188
|
(_g = process.logger) === null || _g === void 0 ? void 0 : _g.success("File ".concat(finalFilePathJSON, " has been created."));
|
|
@@ -384,7 +397,7 @@ function getContentFor(rootDirectory, folderPath, serverType) {
|
|
|
384
397
|
.join('/'), ";\n");
|
|
385
398
|
contentJSON = {
|
|
386
399
|
name: folderName,
|
|
387
|
-
type:
|
|
400
|
+
type: types_1.MemberType.folder,
|
|
388
401
|
members: []
|
|
389
402
|
};
|
|
390
403
|
return [4 /*yield*/, (0, utils_1.listFilesInFolder)(folderPath)];
|
|
@@ -404,7 +417,7 @@ function getContentFor(rootDirectory, folderPath, serverType) {
|
|
|
404
417
|
content += "\n".concat(transformedContent, "\n");
|
|
405
418
|
contentJSON.members.push({
|
|
406
419
|
name: file.replace(/.sas$/, ''),
|
|
407
|
-
type:
|
|
420
|
+
type: types_1.MemberType.service,
|
|
408
421
|
code: (0, utils_2.removeComments)(fileContent)
|
|
409
422
|
});
|
|
410
423
|
return [3 /*break*/, 4];
|
|
@@ -415,7 +428,7 @@ function getContentFor(rootDirectory, folderPath, serverType) {
|
|
|
415
428
|
content += "\n".concat(transformedContent, "\n");
|
|
416
429
|
contentJSON.members.push({
|
|
417
430
|
name: file.replace(/.sas$/, ''),
|
|
418
|
-
type:
|
|
431
|
+
type: types_1.MemberType.file,
|
|
419
432
|
code: fileContentEncoded
|
|
420
433
|
});
|
|
421
434
|
_a.label = 4;
|
|
@@ -57,12 +57,12 @@ var deployToSasViyaWithServicePack_1 = require("../shared/deployToSasViyaWithSer
|
|
|
57
57
|
* @param {object} sasjs - optional configuration object of SAS adapter.
|
|
58
58
|
*/
|
|
59
59
|
function deploy(target, isLocal, sasjs) {
|
|
60
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
61
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var appLoc, buildDestinationFolder_1, finalFilePathJSON, jsonObject, webIndexFileName, deployScripts, buildDestinationFolder, logFilePath, streamConfig;
|
|
62
|
+
var appLoc, buildDestinationFolder_1, finalFilePathJSON, jsonObject, servicesFolder, webIndexFileName, deployScripts, buildDestinationFolder, logFilePath, streamConfig;
|
|
63
63
|
var _this = this;
|
|
64
|
-
return __generator(this, function (
|
|
65
|
-
switch (
|
|
64
|
+
return __generator(this, function (_j) {
|
|
65
|
+
switch (_j.label) {
|
|
66
66
|
case 0:
|
|
67
67
|
if (!(target.serverType === utils_2.ServerType.SasViya &&
|
|
68
68
|
((_a = target.deployConfig) === null || _a === void 0 ? void 0 : _a.deployServicePack))) return [3 /*break*/, 2];
|
|
@@ -72,30 +72,31 @@ function deploy(target, isLocal, sasjs) {
|
|
|
72
72
|
finalFilePathJSON = path_1.default.join(buildDestinationFolder_1, "".concat(target.name, ".json"));
|
|
73
73
|
return [4 /*yield*/, (0, deployToSasViyaWithServicePack_1.deployToSasViyaWithServicePack)(finalFilePathJSON, target, isLocal, true)];
|
|
74
74
|
case 1:
|
|
75
|
-
jsonObject =
|
|
76
|
-
|
|
77
|
-
return (member === null || member === void 0 ? void 0 : member.name) === 'services' && (member === null || member === void 0 ? void 0 : member.type) ===
|
|
78
|
-
})
|
|
79
|
-
(
|
|
80
|
-
(
|
|
75
|
+
jsonObject = _j.sent();
|
|
76
|
+
servicesFolder = jsonObject === null || jsonObject === void 0 ? void 0 : jsonObject.members.find(function (member) {
|
|
77
|
+
return (member === null || member === void 0 ? void 0 : member.name) === 'services' && (member === null || member === void 0 ? void 0 : member.type) === utils_2.MemberType.folder;
|
|
78
|
+
});
|
|
79
|
+
webIndexFileName = (_e = (_d = (_c = servicesFolder === null || servicesFolder === void 0 ? void 0 : servicesFolder.members) === null || _c === void 0 ? void 0 : _c.find(function (member) { return (member === null || member === void 0 ? void 0 : member.type) === utils_2.MemberType.file; })) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : '';
|
|
80
|
+
(_f = process.logger) === null || _f === void 0 ? void 0 : _f.success('Build pack has been successfully deployed.');
|
|
81
|
+
(_g = process.logger) === null || _g === void 0 ? void 0 : _g.success(target.serverType === utils_2.ServerType.SasViya && webIndexFileName
|
|
81
82
|
? "".concat(target.serverUrl, "/SASJobExecution?_file=").concat(appLoc, "/services/").concat(webIndexFileName, "&_debug=2")
|
|
82
83
|
: "".concat(target.serverUrl, "/SASJobExecution?_folder=").concat(appLoc));
|
|
83
|
-
|
|
84
|
+
_j.label = 2;
|
|
84
85
|
case 2: return [4 /*yield*/, (0, getDeployScripts_1.getDeployScripts)(target)];
|
|
85
86
|
case 3:
|
|
86
|
-
deployScripts =
|
|
87
|
-
if (deployScripts.length === 0 && !((
|
|
87
|
+
deployScripts = _j.sent();
|
|
88
|
+
if (deployScripts.length === 0 && !((_h = target.deployConfig) === null || _h === void 0 ? void 0 : _h.deployServicePack)) {
|
|
88
89
|
throw new Error("Deployment failed.\nPlease either enable the 'deployServicePack' option or add deployment script paths to 'deployScripts' in your target's 'deployConfig'.");
|
|
89
90
|
}
|
|
90
91
|
buildDestinationFolder = process.sasjsConstants.buildDestinationFolder;
|
|
91
92
|
logFilePath = buildDestinationFolder;
|
|
92
93
|
return [4 /*yield*/, (0, config_1.getStreamConfig)(target)];
|
|
93
94
|
case 4:
|
|
94
|
-
streamConfig =
|
|
95
|
+
streamConfig = _j.sent();
|
|
95
96
|
if (!(target.serverType === utils_2.ServerType.Sasjs)) return [3 /*break*/, 6];
|
|
96
97
|
return [4 /*yield*/, deployToSasjs(target, sasjs, streamConfig)];
|
|
97
98
|
case 5:
|
|
98
|
-
|
|
99
|
+
_j.sent();
|
|
99
100
|
return [3 /*break*/, 8];
|
|
100
101
|
case 6: return [4 /*yield*/, (0, utils_2.asyncForEach)(deployScripts, function (deployScript) { return __awaiter(_this, void 0, void 0, function () {
|
|
101
102
|
var deployScriptPath, deployScriptContent, linesToExecute, deployScriptName, logPath;
|
|
@@ -139,8 +140,8 @@ function deploy(target, isLocal, sasjs) {
|
|
|
139
140
|
});
|
|
140
141
|
}); })];
|
|
141
142
|
case 7:
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
_j.sent();
|
|
144
|
+
_j.label = 8;
|
|
144
145
|
case 8: return [2 /*return*/];
|
|
145
146
|
}
|
|
146
147
|
});
|
|
@@ -364,7 +365,7 @@ function deployToSasjs(target, sasjs, streamConfig) {
|
|
|
364
365
|
e_2 = _d.sent();
|
|
365
366
|
return [3 /*break*/, 5];
|
|
366
367
|
case 5: return [4 /*yield*/, sasjs
|
|
367
|
-
.deployToSASjs(payload, undefined,
|
|
368
|
+
.deployToSASjs(payload, undefined, authConfig)
|
|
368
369
|
.catch(function (err) {
|
|
369
370
|
var _a;
|
|
370
371
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(err);
|
|
@@ -133,33 +133,36 @@ describe('sasjs cbd with server type SASJS', function () {
|
|
|
133
133
|
webSourcePath: ''
|
|
134
134
|
};
|
|
135
135
|
expect(sasjs.deployToSASjs).toHaveBeenCalledWith({
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
'
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
'
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
136
|
+
appLoc: target.appLoc,
|
|
137
|
+
fileTree: {
|
|
138
|
+
members: [
|
|
139
|
+
{
|
|
140
|
+
name: 'services',
|
|
141
|
+
type: 'folder',
|
|
142
|
+
members: [
|
|
143
|
+
{
|
|
144
|
+
name: 'common',
|
|
145
|
+
type: 'folder',
|
|
146
|
+
members: [
|
|
147
|
+
{
|
|
148
|
+
name: 'appinit',
|
|
149
|
+
type: 'service',
|
|
150
|
+
code: (0, utils_3.removeComments)("".concat(mf_getuser).concat(mp_jsonout).concat(ms_webout).concat(webout) +
|
|
151
|
+
'/* provide additional debug info */\n%global _program;\n%put &=syscc;\n%put user=%mf_getuser();\n%put pgm=&_program;\n%put timestamp=%sysfunc(datetime(),datetime19.);\n* Service Variables start;\n* Service Variables end;\n* SAS Macros start;\n* SAS Macros end;\n* SAS Includes start;\n* SAS Includes end;\n* Binary Files start;\n* Binary Files end;\n* Service start;\nproc sql;\ncreate table areas as select distinct area\n from sashelp.springs;\n%webout(OPEN)\n%webout(OBJ,areas)\n%webout(CLOSE)\n* Service end;')
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'getdata',
|
|
155
|
+
type: 'service',
|
|
156
|
+
code: (0, utils_3.removeComments)("".concat(mf_getuser).concat(mp_jsonout).concat(ms_webout).concat(webout) +
|
|
157
|
+
'/* provide additional debug info */\n%global _program;\n%put &=syscc;\n%put user=%mf_getuser();\n%put pgm=&_program;\n%put timestamp=%sysfunc(datetime(),datetime19.);\n* Service Variables start;\n* Service Variables end;\n* SAS Macros start;\n* SAS Macros end;\n* SAS Includes start;\n* SAS Includes end;\n* Binary Files start;\n* Binary Files end;\n* Service start;\n%webout(FETCH)\nproc sql;\ncreate table springs as select * from sashelp.springs\n where area in (select area from work.areas);\n%webout(OPEN)\n%webout(OBJ,springs)\n%webout(CLOSE)\n* Service end;')
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
}, undefined, undefined);
|
|
163
166
|
return [2 /*return*/];
|
|
164
167
|
}
|
|
165
168
|
});
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { Target } from '@sasjs/utils';
|
|
2
|
-
|
|
3
|
-
export declare function deployToSasViyaWithServicePack(jsonFilePath: string, target: Target, isLocal: boolean, isForced?: boolean): Promise<ServicePack>;
|
|
1
|
+
import { FileTree, Target } from '@sasjs/utils';
|
|
2
|
+
export declare function deployToSasViyaWithServicePack(jsonFilePath: string, target: Target, isLocal: boolean, isForced?: boolean): Promise<FileTree>;
|
|
@@ -85,9 +85,9 @@ exports.deployToSasViyaWithServicePack = deployToSasViyaWithServicePack;
|
|
|
85
85
|
var populateCodeInServicePack = function (json) {
|
|
86
86
|
var _a;
|
|
87
87
|
return (_a = json === null || json === void 0 ? void 0 : json.members) === null || _a === void 0 ? void 0 : _a.forEach(function (member) {
|
|
88
|
-
if (member.type ===
|
|
88
|
+
if (member.type === utils_1.MemberType.file)
|
|
89
89
|
member.code = (0, js_base64_1.decode)(member.code);
|
|
90
|
-
if (member.type ===
|
|
90
|
+
if (member.type === utils_1.MemberType.folder)
|
|
91
91
|
populateCodeInServicePack(member);
|
|
92
92
|
});
|
|
93
93
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TestResults } from '../../../types';
|
|
1
|
+
import { TestResults, TestResultCsv } from '../../../types';
|
|
2
2
|
export declare const saveLog: (outDirectory: string, test: string, log: string, lineBreak?: boolean) => Promise<void>;
|
|
3
3
|
export declare const saveResultJson: (outDirectory: string, result: TestResults) => Promise<string | false>;
|
|
4
4
|
export declare const saveResultCsv: (outDirectory: string, result: TestResults, options?: {}) => Promise<{
|
|
5
|
-
csvData:
|
|
5
|
+
csvData: TestResultCsv[];
|
|
6
6
|
csvPath: string;
|
|
7
7
|
}>;
|
|
8
8
|
export declare const saveResultXml: (outDirectory: string, result: TestResults) => Promise<string>;
|
|
@@ -19,5 +19,15 @@ exports.testResponses = {
|
|
|
19
19
|
TEST_DESCRIPTION: 'examplemacro test.1 description',
|
|
20
20
|
TEST_RESULT: 'PASS'
|
|
21
21
|
}
|
|
22
|
+
],
|
|
23
|
+
'notexisting.test': [
|
|
24
|
+
{
|
|
25
|
+
TEST_DESCRIPTION: 'examplemacro test.1 description',
|
|
26
|
+
TEST_RESULT: 'PASS'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
TEST_DESCRIPTION: 'examplemacro test.1 description',
|
|
30
|
+
TEST_RESULT: 'FAIL'
|
|
31
|
+
}
|
|
22
32
|
]
|
|
23
33
|
};
|
|
@@ -71,6 +71,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
71
71
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
72
|
var path_1 = __importDefault(require("path"));
|
|
73
73
|
var test_1 = require("../test");
|
|
74
|
+
var types_1 = require("../../../types");
|
|
74
75
|
var utils_1 = require("@sasjs/utils");
|
|
75
76
|
var test_2 = require("../../../utils/test");
|
|
76
77
|
var setConstants_1 = require("../../../utils/setConstants");
|
|
@@ -78,6 +79,9 @@ var dotenv_1 = __importDefault(require("dotenv"));
|
|
|
78
79
|
var __1 = require("../..");
|
|
79
80
|
var sasJsModules = __importStar(require("../../../utils/createSASjsInstance"));
|
|
80
81
|
var testResponses_1 = require("./mockedAdapter/testResponses");
|
|
82
|
+
var fileModule = __importStar(require("@sasjs/utils/file"));
|
|
83
|
+
var utilsModule = __importStar(require("@sasjs/utils/utils"));
|
|
84
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
81
85
|
describe('sasjs test', function () {
|
|
82
86
|
var expectedCoverageLcov = "TN:testsetup.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:exampleprogram.test.sas\nSF:jobs/jobs/exampleprogram.sas\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:standalone.test.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:examplemacro.test.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:shouldFail.test.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:dostuff.test.0.sas\nSF:services/admin/dostuff.sas\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:dostuff.test.1.sas\nSF:services/admin/dostuff.sas\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record\nTN:testteardown.sas\nSF:standalone\nFNF:1\nFNH:1\nLF:1\nLH:1\nBRF:1\nBRH:1\nend_of_record";
|
|
83
87
|
describe('SASVIYA', function () {
|
|
@@ -576,6 +580,25 @@ describe('sasjs test', function () {
|
|
|
576
580
|
}
|
|
577
581
|
});
|
|
578
582
|
}); });
|
|
583
|
+
it('should FAIL test suit if any test has status FAIL', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
584
|
+
var testService;
|
|
585
|
+
return __generator(this, function (_a) {
|
|
586
|
+
switch (_a.label) {
|
|
587
|
+
case 0:
|
|
588
|
+
testService = 'notexisting';
|
|
589
|
+
jest.spyOn(process.logger, 'table');
|
|
590
|
+
jest.spyOn(utilsModule, 'uuidv4').mockImplementation(function () { return 'uuidv4'; });
|
|
591
|
+
jest.spyOn(fileModule, 'readFile').mockImplementation(function () {
|
|
592
|
+
return Promise.resolve("{\n \"tests\": [\n \"tests/macros/".concat(testService, ".test.sas\"\n ],\n \"testSetUp\": \"\",\n \"testTearDown\": \"\"\n}"));
|
|
593
|
+
});
|
|
594
|
+
return [4 /*yield*/, (0, test_1.runTest)(target, undefined, undefined, undefined)];
|
|
595
|
+
case 1:
|
|
596
|
+
_a.sent();
|
|
597
|
+
expect(process.logger.table).toHaveBeenCalledWith([['uuidv4', testService, chalk_1.default.redBright(types_1.TestResultStatus.fail)]], { head: ['SASjs Test ID', 'Test Target', 'Test Suite Result'] });
|
|
598
|
+
return [2 /*return*/];
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
}); });
|
|
579
602
|
});
|
|
580
603
|
});
|
|
581
604
|
function generateTarget(serverType) {
|
|
@@ -86,11 +86,12 @@ var path_1 = __importDefault(require("path"));
|
|
|
86
86
|
var chalk_1 = __importDefault(require("chalk"));
|
|
87
87
|
var utils_2 = require("../../utils/utils");
|
|
88
88
|
var createSASjsInstance_1 = require("../../utils/createSASjsInstance");
|
|
89
|
+
// interface
|
|
89
90
|
function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
90
91
|
var _a, _b;
|
|
91
92
|
if (testRegExps === void 0) { testRegExps = []; }
|
|
92
93
|
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
-
var testFlowData, testFlow, flow, sasjs, authConfig, username, password, _c, sas9CredentialsError, e_1, result, isCodeExamplePrinted, printCodeExample, jsonPath, xmlPath, _d, csvData, csvPath, coverageReportPath, resultTable, testsCount, passedTestsCount, testsWithResultsCount;
|
|
94
|
+
var testFlowData, testFlow, flow, sasjs, authConfig, username, password, _c, sas9CredentialsError, e_1, result, isCodeExamplePrinted, printCodeExample, jsonPath, xmlPath, _d, csvData, csvPath, coverageReportPath, resultTable, testSuites, testsCount, passedTestsCount, testsWithResultsCount;
|
|
94
95
|
var _this = this;
|
|
95
96
|
return __generator(this, function (_e) {
|
|
96
97
|
switch (_e.label) {
|
|
@@ -300,7 +301,8 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
300
301
|
});
|
|
301
302
|
}
|
|
302
303
|
}
|
|
303
|
-
else if (target.serverType
|
|
304
|
+
else if (target.serverType === utils_1.ServerType.SasViya ||
|
|
305
|
+
target.serverType === utils_1.ServerType.Sas9) {
|
|
304
306
|
(0, displayResult_1.displayError)({}, "'test_results' not found in server response, to debug click ".concat(testUrl));
|
|
305
307
|
printCodeExample();
|
|
306
308
|
}
|
|
@@ -353,11 +355,26 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
353
355
|
coverageReportPath = _e.sent();
|
|
354
356
|
resultTable = {};
|
|
355
357
|
if (Array.isArray(csvData)) {
|
|
356
|
-
csvData.
|
|
357
|
-
return
|
|
358
|
-
|
|
359
|
-
|
|
358
|
+
testSuites = csvData.reduce(function (acc, item) {
|
|
359
|
+
if (!acc.filter(function (i) { return i.sasjs_test_id === item.sasjs_test_id; }).length)
|
|
360
|
+
acc.push(item);
|
|
361
|
+
return acc;
|
|
362
|
+
}, []);
|
|
363
|
+
testSuites.forEach(function (test) {
|
|
364
|
+
var passedTests = csvData.filter(function (item) {
|
|
365
|
+
return item.sasjs_test_id === test.sasjs_test_id &&
|
|
366
|
+
item.test_suite_result === types_1.TestResultStatus.pass;
|
|
360
367
|
});
|
|
368
|
+
var failedTests = csvData.filter(function (item) {
|
|
369
|
+
return item.sasjs_test_id === test.sasjs_test_id &&
|
|
370
|
+
item.test_suite_result === types_1.TestResultStatus.fail;
|
|
371
|
+
});
|
|
372
|
+
resultTable[test.sasjs_test_id] = {
|
|
373
|
+
test_target: test.test_target,
|
|
374
|
+
test_suite_result: passedTests.length && !failedTests.length
|
|
375
|
+
? types_1.TestResultStatus.pass
|
|
376
|
+
: types_1.TestResultStatus.fail
|
|
377
|
+
};
|
|
361
378
|
});
|
|
362
379
|
}
|
|
363
380
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.table(Object.keys(resultTable).map(function (key) { return [
|
package/build/types/index.d.ts
CHANGED
|
@@ -2,6 +2,5 @@ export { CommandBase } from './command/commandBase';
|
|
|
2
2
|
export { File, FilePath } from './file';
|
|
3
3
|
export { Folder } from './folder';
|
|
4
4
|
export { TargetScope } from './targetScope';
|
|
5
|
-
export { TestFlow, Coverage, CoverageType, CoverageState, TestResults, TestResultStatus, TestDescription, TestResult, TestResultDescription } from './testing';
|
|
5
|
+
export { TestFlow, Coverage, CoverageType, CoverageState, TestResults, TestResultStatus, TestDescription, TestResult, TestResultDescription, TestResultCsv } from './testing';
|
|
6
6
|
export { Flow, FlowWave, FlowWaveJob } from './flow';
|
|
7
|
-
export { ServicePack, ServicePackMember } from './servicePack';
|
package/build/types/testing.d.ts
CHANGED
|
@@ -42,3 +42,11 @@ export interface TestResult {
|
|
|
42
42
|
export interface TestResults {
|
|
43
43
|
sasjs_test_meta: TestDescription[];
|
|
44
44
|
}
|
|
45
|
+
export interface TestResultCsv {
|
|
46
|
+
test_target: string;
|
|
47
|
+
test_loc: string;
|
|
48
|
+
sasjs_test_id: string;
|
|
49
|
+
test_suite_result: TestResultStatus.pass | TestResultStatus.fail;
|
|
50
|
+
test_description: string;
|
|
51
|
+
test_url: string;
|
|
52
|
+
}
|
package/build/utils/test.js
CHANGED
|
@@ -413,6 +413,9 @@ var updateTarget = function (targetJson, targetName, isLocal) {
|
|
|
413
413
|
targetIndex = config.targets.findIndex(function (t) { return t.name === targetName; });
|
|
414
414
|
if (!(targetIndex >= 0)) return [3 /*break*/, 9];
|
|
415
415
|
config.targets.splice(targetIndex, 1, __assign(__assign({}, config.targets[targetIndex]), targetJson));
|
|
416
|
+
config = __assign(__assign({}, config), { targets: config.targets.map(function (target) { return (__assign(__assign({}, target), { serverUrl: process.env["".concat(target.serverType === types_1.ServerType.SasViya
|
|
417
|
+
? 'VIYA'
|
|
418
|
+
: target.serverType, "_SERVER_URL")] })); }) });
|
|
416
419
|
if (!isLocal) return [3 /*break*/, 6];
|
|
417
420
|
return [4 /*yield*/, (0, config_1.saveLocalConfigFile)(JSON.stringify(config, null, 2))];
|
|
418
421
|
case 5:
|
package/package.json
CHANGED
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@sasjs/adapter": "3.8.
|
|
50
|
+
"@sasjs/adapter": "3.8.2",
|
|
51
51
|
"@sasjs/core": "4.15.3",
|
|
52
52
|
"@sasjs/lint": "1.11.2",
|
|
53
|
-
"@sasjs/utils": "2.
|
|
53
|
+
"@sasjs/utils": "2.42.0",
|
|
54
54
|
"chalk": "4.1.2",
|
|
55
55
|
"csv-stringify": "5.6.5",
|
|
56
56
|
"dotenv": "10.0.0",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"typescript": "4.5.4",
|
|
95
95
|
"util": "0.12.4"
|
|
96
96
|
},
|
|
97
|
-
"version": "3.12.
|
|
97
|
+
"version": "3.12.5"
|
|
98
98
|
}
|