Skip to content

Commit 6aa16ad

Browse files
authored
Merge pull request #35 from alexalvess/feature/change-coverage-model
insert other way to replace variables
2 parents c5675e0 + 591b195 commit 6aa16ad

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

buildAndReleaseTask/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ function processPostmanTestResults(testType: TestType, testResultPath: string) {
9797
debug(`Files found in Directory: ${JSON.stringify(files)}`);
9898
});
9999

100+
debug(`Test type selected: ${testType}`);
100101
if(testType === TestType.Postman) {
101102
let fileTestResult = fs.readFileSync(testResultPath, 'utf8');
102103
let jsonTestResult = JSON.parse(fileTestResult);

buildAndReleaseTask/models/EndpointModel.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class EndpointModel {
1515
return new EndpointModel(id, path, verb, isSuccess);
1616
}
1717

18-
public static buildFullPath(paths: string[], queries: {key: string, value: string}[]): string {
18+
public static buildFullPath(paths: string[], queries: {key: string, value: string}[], variables: [any]): string {
1919
let fullPath = '';
2020

2121
if(!paths || paths.length === 0)
@@ -24,10 +24,15 @@ export class EndpointModel {
2424
paths.forEach(el => {
2525
if(el.includes(':'))
2626
fullPath += `/{${el.slice(1)}}`;
27-
else
27+
else if(el.includes('{{')) {
28+
const key = el.replace('{{', '').replace('}}', '');
29+
fullPath += `/${variables.find(f => f.key === key)?.value}`
30+
} else
2831
fullPath += `/${el}`;
2932
});
3033

34+
fullPath = fullPath.substring(fullPath.indexOf("/api"));
35+
3136
queries.forEach((el, index) => {
3237
if(index === 0)
3338
fullPath += '?';

buildAndReleaseTask/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"version": {
1111
"Major": 0,
1212
"Minor": 1,
13-
"Patch": 34
13+
"Patch": 35
1414
},
1515
"instanceNameFormat": "API Coverage Test",
1616
"groups": [

buildAndReleaseTask/utils/mappers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ export function postmanMap(testResult: any): EndpointModel[] {
44
if(!testResult)
55
throw new Error("No test were found.");
66

7-
return discoverPath(testResult.collection.item, testResult.run.executions, []);
7+
return discoverPath(testResult.collection.item, testResult.run.executions, testResult.environment.values, []);
88
}
99

10-
function discoverPath(items: [], executions: [], paths: Array<EndpointModel>): Array<EndpointModel> {
10+
function discoverPath(items: [], executions: [], variables: [any], paths: Array<EndpointModel>): Array<EndpointModel> {
1111
items.forEach((el: any) => {
1212
if(el.item)
13-
return discoverPath(el.item, executions, paths);
13+
return discoverPath(el.item, executions, variables, paths);
1414

1515
const success = hasError(executions, el.id);
1616

17-
const fullPath = EndpointModel.buildFullPath(el.request.url.path, el.request.url.query);
17+
const fullPath = EndpointModel.buildFullPath(el.request.url.path, el.request.url.query, variables);
1818
paths.push(new EndpointModel(el.id, fullPath, el.request.method, !success));
1919
});
2020

vss-extension.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifestVersion": 1,
33
"id": "task-702d7430-c3a9-422a-87f2-569ed16ba6be",
44
"name": "Coverage API Test",
5-
"version": "0.0.105",
5+
"version": "0.0.106",
66
"publisher": "AlexAlves",
77
"targets": [
88
{

0 commit comments

Comments
 (0)