@skyramp/skyramp 0.4.39 → 0.4.41
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/lib/dev-darwin-amd64.dylib +0 -0
- package/lib/dev-darwin-arm64.dylib +0 -0
- package/lib/dev-linux-386.so +0 -0
- package/lib/dev-linux-amd64.so +0 -0
- package/lib/dev-windows-amd64.dll +0 -0
- package/package.json +1 -1
- package/src/classes/Endpoint.js +33 -22
- package/src/classes/Scenario.js +8 -10
- package/src/utils.js +5 -3
|
Binary file
|
|
Binary file
|
package/lib/dev-linux-386.so
CHANGED
|
Binary file
|
package/lib/dev-linux-amd64.so
CHANGED
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/src/classes/Endpoint.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const lib = require('../lib');
|
|
2
|
-
const { getYamlBytes, readDataFromFile } = require('../utils');
|
|
2
|
+
const { getYamlBytes, readDataFromFile, SKYRAMP_YAML_VERSION } = require('../utils');
|
|
3
3
|
const writeMockDescriptionWrapper = lib.func('writeMockDescriptionWrapper', 'string', ['string', 'string']);
|
|
4
4
|
|
|
5
5
|
class Endpoint {
|
|
@@ -8,14 +8,14 @@ class Endpoint {
|
|
|
8
8
|
const endpoint = JSON.parse(endpointData);
|
|
9
9
|
this.services = endpoint.services;
|
|
10
10
|
this.endpoint = endpoint.endpoints[0];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.responseValues = endpoint.responseValues;
|
|
11
|
+
|
|
12
|
+
this.responses = endpoint.responses;
|
|
13
|
+
|
|
15
14
|
this.mockDescription = {
|
|
15
|
+
version: SKYRAMP_YAML_VERSION,
|
|
16
16
|
services: this.services,
|
|
17
17
|
endpoints: [this.endpoint],
|
|
18
|
-
|
|
18
|
+
responses: this.responses
|
|
19
19
|
};
|
|
20
20
|
} catch(error) {
|
|
21
21
|
throw new Error(endpointData);
|
|
@@ -23,25 +23,36 @@ class Endpoint {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
mockMethod(methodName, mockObject, dynamic=false) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
26
|
+
if (!this.endpoint.methods.some(method => method.name === methodName)) {
|
|
27
|
+
throw new Error(`Method ${methodName} not found`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
for (const response of this.responses) {
|
|
31
|
+
if (response.methodName === methodName && response.endpointName === this.endpoint.name) {
|
|
32
|
+
if (dynamic) {
|
|
33
|
+
response.javascriptPath = mockObject;
|
|
34
|
+
delete response.blob;
|
|
35
|
+
} else {
|
|
36
|
+
response.blob = mockObject.responseValue.blob;
|
|
37
|
+
delete response.javascriptPath;
|
|
41
38
|
}
|
|
39
|
+
|
|
40
|
+
return;
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
|
|
44
|
+
newResponse = {
|
|
45
|
+
methodName: methodName,
|
|
46
|
+
endpointName: this.endpoint.name
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (dynamic) {
|
|
50
|
+
newResponse.javascriptPath = mock;
|
|
51
|
+
} else {
|
|
52
|
+
newResponse.blob = mockObject.responseValue.blob;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this.responses.append(newResponse)
|
|
45
56
|
}
|
|
46
57
|
|
|
47
58
|
mockMethodFromFile(methodName, fileName) {
|
package/src/classes/Scenario.js
CHANGED
|
@@ -15,14 +15,14 @@ class Scenario {
|
|
|
15
15
|
addRequest(endpoint, methodName, requestObject=undefined, dynamic=false) {
|
|
16
16
|
this.buildRequestsFromEndpoint(endpoint);
|
|
17
17
|
for (const request of this.requests) {
|
|
18
|
-
if (request.
|
|
18
|
+
if (request.methodName === methodName) {
|
|
19
19
|
if (dynamic) {
|
|
20
|
-
request.
|
|
21
|
-
delete request.
|
|
20
|
+
request.javascriptPath = requestObject;
|
|
21
|
+
delete request.blob;
|
|
22
22
|
} else if (requestObject !== undefined) {
|
|
23
|
-
request.
|
|
23
|
+
request.blob = requestObject.requestValue.blob;
|
|
24
24
|
}
|
|
25
|
-
this.steps.push({
|
|
25
|
+
this.steps.push({ requestName: request.name });
|
|
26
26
|
return request.name;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -38,12 +38,10 @@ class Scenario {
|
|
|
38
38
|
if (this.endpoints.indexOf(endpoint.endpoint) !== -1) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
const { responseValue, proxy, ...rest } = method;
|
|
43
|
-
return rest;
|
|
44
|
-
});
|
|
41
|
+
|
|
45
42
|
this.services.push(...endpoint.services);
|
|
46
|
-
this.endpoints.push(
|
|
43
|
+
this.endpoints.push(endpoint.endpoint);
|
|
44
|
+
|
|
47
45
|
const yamlContent = getYamlBytes(endpoint.mockDescription);
|
|
48
46
|
const response = buildRequestsWrapper(yamlContent);
|
|
49
47
|
try {
|
package/src/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const yaml = require('js-yaml');
|
|
4
|
+
const SKYRAMP_YAML_VERSION = "v1"
|
|
4
5
|
|
|
5
6
|
function getYamlBytes(jsonObject) {
|
|
6
7
|
try {
|
|
@@ -13,11 +14,11 @@ function getYamlBytes(jsonObject) {
|
|
|
13
14
|
|
|
14
15
|
function createTestDescriptionFromScenario(scenario) {
|
|
15
16
|
return {
|
|
17
|
+
version: SKYRAMP_YAML_VERSION,
|
|
16
18
|
test: {
|
|
17
|
-
name: scenario.name,
|
|
18
19
|
testPattern: [{
|
|
19
20
|
startAt: 1,
|
|
20
|
-
|
|
21
|
+
scenarioName: scenario.name
|
|
21
22
|
}]
|
|
22
23
|
},
|
|
23
24
|
services: scenario.services,
|
|
@@ -54,5 +55,6 @@ function readDataFromFile(filename) {
|
|
|
54
55
|
module.exports = {
|
|
55
56
|
createTestDescriptionFromScenario,
|
|
56
57
|
getYamlBytes,
|
|
57
|
-
readDataFromFile
|
|
58
|
+
readDataFromFile,
|
|
59
|
+
SKYRAMP_YAML_VERSION
|
|
58
60
|
}
|