Skip to content

Commit

Permalink
Update engines field. Improve workflow file
Browse files Browse the repository at this point in the history
  • Loading branch information
AmsterGet committed Jan 13, 2022
1 parent 36cc412 commit 5cbf65a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
3 changes: 1 addition & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"indent": ["error", 2],
"max-len": ["error", 120],
"valid-jsdoc": ["error", { "requireReturn": false }],
"consistent-return": 0,
"prefer-object-spread": 0
"consistent-return": 0
}
}
5 changes: 4 additions & 1 deletion .github/workflows/CI-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ on:
- README.md
- CHANGELOG.md
pull_request:
branches:
- develop
- master

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [8, 12]
node: [10, 12, 14, 16]
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
37 changes: 19 additions & 18 deletions lib/report-portal-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ class RPClient {
this.isLaunchMergeRequired = params.isLaunchMergeRequired === undefined ? false : params.isLaunchMergeRequired;
this.map = {};
this.baseURL = [params.endpoint, params.project].join('/');
const headers = Object.assign({
const headers = {
'User-Agent': 'NodeJS',
Authorization: `bearer ${params.token}`,
}, params.headers || {});
...(params.headers || {}),
};
this.headers = headers;
this.token = params.token;
this.config = params;
Expand Down Expand Up @@ -175,11 +176,12 @@ class RPClient {
const attributes = Array.isArray(launchDataRQ.attributes)
? launchDataRQ.attributes.concat(systemAttr)
: systemAttr;
const launchData = Object.assign(
{ name: this.config.launch || 'Test launch name', startTime: this.helpers.now() },
launchDataRQ,
{ attributes },
);
const launchData = {
name: this.config.launch || 'Test launch name',
startTime: this.helpers.now(),
...launchDataRQ,
attributes,
};

this.map[tempId] = this.getNewItemObj((resolve, reject) => {
const url = 'launch';
Expand Down Expand Up @@ -224,7 +226,7 @@ class RPClient {
return this.getRejectAnswer(launchTempId, new Error(`Launch "${launchTempId}" not found`));
}

const finishExecutionData = Object.assign({ endTime: this.helpers.now() }, finishExecutionRQ);
const finishExecutionData = { endTime: this.helpers.now(), ...finishExecutionRQ };

launchObj.finishSend = true;
Promise.all(launchObj.children.map((itemId) => this.map[itemId].promiseFinish))
Expand Down Expand Up @@ -411,9 +413,7 @@ class RPClient {

const testCaseId = testItemDataRQ.testCaseId
|| helpers.generateTestCaseId(testItemDataRQ.codeRef, testItemDataRQ.parameters);
const testItemData = Object.assign({
startTime: this.helpers.now(),
}, testItemDataRQ, testCaseId && { testCaseId });
const testItemData = { startTime: this.helpers.now(), ...testItemDataRQ, ...(testCaseId && { testCaseId }) };

let parentPromise = launchObj.promiseStart;
if (parentTempId) {
Expand Down Expand Up @@ -504,9 +504,11 @@ class RPClient {
return this.getRejectAnswer(itemTempId, new Error(`Item "${itemTempId}" not found`));
}

const finishTestItemData = Object.assign({
const finishTestItemData = {
endTime: this.helpers.now(),
}, itemObj.children.length ? {} : { status: RP_STATUSES.PASSED }, finishTestItemRQ);
...(itemObj.children.length ? {} : { status: RP_STATUSES.PASSED }),
...finishTestItemRQ,
};

itemObj.finishSend = true;
Promise.all(itemObj.children.map((itemId) => this.map[itemId] && this.map[itemId].promiseFinish))
Expand Down Expand Up @@ -563,11 +565,12 @@ class RPClient {
}

sendLog(itemTempId, saveLogRQ, fileObj) {
const saveLogData = Object.assign({
const saveLogData = {
time: this.helpers.now(),
message: '',
level: '',
}, saveLogRQ);
...saveLogRQ,
};

if (fileObj) {
return this.sendLogWithFile(itemTempId, saveLogData, fileObj);
Expand Down Expand Up @@ -654,9 +657,7 @@ class RPClient {
url,
this.buildMultiPartStream([saveLogRQ], fileObj, MULTIPART_BOUNDARY),
{
headers: Object.assign({}, this.headers, {
'Content-Type': `multipart/form-data; boundary=${MULTIPART_BOUNDARY}`,
}),
headers: { ...this.headers, 'Content-Type': `multipart/form-data; boundary=${MULTIPART_BOUNDARY}` },
},
)
.then((response) => response)
Expand Down
15 changes: 8 additions & 7 deletions lib/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ class RestClient {
}

static request(method, url, data, options = {}) {
return axios(Object.assign({
return axios({
method,
url,
data,
timeout: DEFAULT_MAX_CONNECTION_TIME_MS,
}, options))
...options,
})
.then((response) => response.data)
.catch((error) => {
const errorMessage = error.message;
Expand Down Expand Up @@ -64,23 +65,23 @@ class RestClient {
}

create(path, data, options = { headers: this.headers }) {
return RestClient.request('POST', this.buildPath(path), data, Object.assign({}, options, this.getRestConfig()));
return RestClient.request('POST', this.buildPath(path), data, { ...options, ...this.getRestConfig() });
}

retrieve(path, options = { headers: this.headers }) {
return RestClient.request('GET', this.buildPath(path), {}, Object.assign({}, options, this.getRestConfig()));
return RestClient.request('GET', this.buildPath(path), {}, { ...options, ...this.getRestConfig() });
}

update(path, data, options = { headers: this.headers }) {
return RestClient.request('PUT', this.buildPath(path), data, Object.assign({}, options, this.getRestConfig()));
return RestClient.request('PUT', this.buildPath(path), data, { ...options, ...this.getRestConfig() });
}

delete(path, data, options = { headers: this.headers }) {
return RestClient.request(
'DELETE',
this.buildPath(path),
data,
Object.assign({}, options, this.getRestConfig()),
{ ...options, ...this.getRestConfig() },
);
}

Expand All @@ -89,7 +90,7 @@ class RestClient {
'GET',
this.buildPathToSyncAPI(path),
{},
Object.assign({}, options, this.getRestConfig()),
{ ...options, ...this.getRestConfig() },
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
],
"main": "./lib/report-portal-client",
"engines": {
"node": ">= 8.0.x"
"node": ">= 10.0.0"
},
"dependencies": {
"axios": "^0.24.0",
Expand Down

0 comments on commit 5cbf65a

Please sign in to comment.