Skip to content

Commit e1c314d

Browse files
authored
Merge pull request #20 from Xray-App/multipart_test_testexec_fix
proper handling of json content for test and testexec; fix #15
2 parents f9a54cd + 1609d26 commit e1c314d

4 files changed

Lines changed: 20 additions & 20 deletions

File tree

__tests__/xray-cloud-client.spec.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ describe("JUnit multipart endpoint", () => {
13461346
expect(parts[1].filename).toEqual("info.json");
13471347
expect(parts[1].type).toEqual("application/json");
13481348
expect(parts[1].data.toString("utf-8")).toEqual(
1349-
reportConfig.testExecInfo.toString("utf-8")
1349+
JSON.stringify(reportConfig.testExecInfo)
13501350
);
13511351
} catch (error: any) {
13521352
throw error;
@@ -1561,7 +1561,7 @@ describe("TestNG multipart endpoint", () => {
15611561
expect(parts[1].filename).toEqual("info.json");
15621562
expect(parts[1].type).toEqual("application/json");
15631563
expect(parts[1].data.toString("utf-8")).toEqual(
1564-
reportConfig.testExecInfo.toString("utf-8")
1564+
JSON.stringify(reportConfig.testExecInfo)
15651565
);
15661566
} catch (error: any) {
15671567
throw error;
@@ -1776,7 +1776,7 @@ describe("Nunit multipart endpoint", () => {
17761776
expect(parts[1].filename).toEqual("info.json");
17771777
expect(parts[1].type).toEqual("application/json");
17781778
expect(parts[1].data.toString("utf-8")).toEqual(
1779-
reportConfig.testExecInfo.toString("utf-8")
1779+
JSON.stringify(reportConfig.testExecInfo)
17801780
);
17811781
} catch (error: any) {
17821782
throw error;
@@ -1994,7 +1994,7 @@ describe("xunit multipart endpoint", () => {
19941994
expect(parts[1].filename).toEqual("info.json");
19951995
expect(parts[1].type).toEqual("application/json");
19961996
expect(parts[1].data.toString("utf-8")).toEqual(
1997-
reportConfig.testExecInfo.toString("utf-8")
1997+
JSON.stringify(reportConfig.testExecInfo)
19981998
);
19991999
} catch (error: any) {
20002000
throw error;
@@ -2209,7 +2209,7 @@ describe("Robot Framework multipart endpoint", () => {
22092209
expect(parts[1].filename).toEqual("info.json");
22102210
expect(parts[1].type).toEqual("application/json");
22112211
expect(parts[1].data.toString("utf-8")).toEqual(
2212-
reportConfig.testExecInfo.toString("utf-8")
2212+
JSON.stringify(reportConfig.testExecInfo)
22132213
);
22142214
} catch (error: any) {
22152215
throw error;
@@ -2427,7 +2427,7 @@ describe("Cucumber multipart endpoint", () => {
24272427
expect(parts[1].filename).toEqual("info.json");
24282428
expect(parts[1].type).toEqual("application/json");
24292429
expect(parts[1].data.toString("utf-8")).toEqual(
2430-
reportConfig.testExecInfo.toString("utf-8")
2430+
JSON.stringify(reportConfig.testExecInfo)
24312431
);
24322432
} catch (error: any) {
24332433
throw error;
@@ -2585,7 +2585,7 @@ describe("Behave multipart endpoint", () => {
25852585
expect(parts[1].filename).toEqual("info.json");
25862586
expect(parts[1].type).toEqual("application/json");
25872587
expect(parts[1].data.toString("utf-8")).toEqual(
2588-
reportConfig.testExecInfo.toString("utf-8")
2588+
JSON.stringify(reportConfig.testExecInfo)
25892589
);
25902590
} catch (error: any) {
25912591
throw error;
@@ -2746,7 +2746,7 @@ describe("Xray JSON multipart endpoint", () => {
27462746
expect(parts[1].filename).toEqual("info.json");
27472747
expect(parts[1].type).toEqual("application/json");
27482748
expect(parts[1].data.toString("utf-8")).toEqual(
2749-
reportConfig.testExecInfo.toString("utf-8")
2749+
JSON.stringify(reportConfig.testExecInfo)
27502750
);
27512751
} catch (error: any) {
27522752
throw error;

__tests__/xray-datacenter-client.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ describe("JUnit multipart endpoint", () => {
13631363
expect(parts[1].filename).toEqual("info.json");
13641364
expect(parts[1].type).toEqual("application/json");
13651365
expect(parts[1].data.toString("utf-8")).toEqual(
1366-
reportConfig.testExecInfo.toString("utf-8")
1366+
JSON.stringify(reportConfig.testExecInfo)
13671367
);
13681368
});
13691369

@@ -1574,7 +1574,7 @@ describe("TestNG multipart endpoint", () => {
15741574
expect(parts[1].filename).toEqual("info.json");
15751575
expect(parts[1].type).toEqual("application/json");
15761576
expect(parts[1].data.toString("utf-8")).toEqual(
1577-
reportConfig.testExecInfo.toString("utf-8")
1577+
JSON.stringify(reportConfig.testExecInfo)
15781578
);
15791579
});
15801580

@@ -1789,7 +1789,7 @@ describe("Nunit multipart endpoint", () => {
17891789
expect(parts[1].filename).toEqual("info.json");
17901790
expect(parts[1].type).toEqual("application/json");
17911791
expect(parts[1].data.toString("utf-8")).toEqual(
1792-
reportConfig.testExecInfo.toString("utf-8")
1792+
JSON.stringify(reportConfig.testExecInfo)
17931793
);
17941794
} catch (error: any) {
17951795
throw error;
@@ -2028,7 +2028,7 @@ describe("xunit multipart endpoint", () => {
20282028
expect(parts[1].filename).toEqual("info.json");
20292029
expect(parts[1].type).toEqual("application/json");
20302030
expect(parts[1].data.toString("utf-8")).toEqual(
2031-
reportConfig.testExecInfo.toString("utf-8")
2031+
JSON.stringify(reportConfig.testExecInfo)
20322032
);
20332033
} catch (error: any) {
20342034
throw error;
@@ -2254,7 +2254,7 @@ describe("Robot Framework multipart endpoint", () => {
22542254
expect(parts[1].filename).toEqual("info.json");
22552255
expect(parts[1].type).toEqual("application/json");
22562256
expect(parts[1].data.toString("utf-8")).toEqual(
2257-
reportConfig.testExecInfo.toString("utf-8")
2257+
JSON.stringify(reportConfig.testExecInfo)
22582258
);
22592259
} catch (error: any) {
22602260
throw error;
@@ -2490,7 +2490,7 @@ describe("Cucumber multipart endpoint", () => {
24902490
expect(parts[1].filename).toEqual("info.json");
24912491
expect(parts[1].type).toEqual("application/json");
24922492
expect(parts[1].data.toString("utf-8")).toEqual(
2493-
reportConfig.testExecInfo.toString("utf-8")
2493+
JSON.stringify(reportConfig.testExecInfo)
24942494
);
24952495
} catch (error: any) {
24962496
throw error;
@@ -2671,7 +2671,7 @@ describe("Behave multipart endpoint", () => {
26712671
expect(parts[1].filename).toEqual("info.json");
26722672
expect(parts[1].type).toEqual("application/json");
26732673
expect(parts[1].data.toString("utf-8")).toEqual(
2674-
reportConfig.testExecInfo.toString("utf-8")
2674+
JSON.stringify(reportConfig.testExecInfo)
26752675
);
26762676
} catch (error: any) {
26772677
throw error;
@@ -2857,7 +2857,7 @@ describe("Xray JSON multipart endpoint", () => {
28572857
expect(parts[1].filename).toEqual("info.json");
28582858
expect(parts[1].type).toEqual("application/json");
28592859
expect(parts[1].data.toString("utf-8")).toEqual(
2860-
reportConfig.testExecInfo.toString("utf-8")
2860+
JSON.stringify(reportConfig.testExecInfo)
28612861
);
28622862
} catch (error: any) {
28632863
throw error;

src/xray-cloud-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@ export class XrayCloudClient {
225225
if (config.testInfoFile !== undefined)
226226
testInfoContent = fs.readFileSync(config.testInfoFile).toString();
227227
if (config.testInfo !== undefined)
228-
testInfoContent = config.testInfo.toString();
228+
testInfoContent = JSON.stringify(config.testInfo);
229229
if (config.testExecInfoFile !== undefined)
230230
testExecInfoContent = fs
231231
.readFileSync(config.testExecInfoFile)
232232
.toString();
233-
else testExecInfoContent = config.testExecInfo.toString();
233+
else testExecInfoContent = JSON.stringify(config.testExecInfo);
234234
} catch (error: any) {
235235
throw new XrayErrorResponse(error.message);
236236
}

src/xray-datacenter-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,12 @@ export class XrayDatacenterClient {
231231
if (config.testInfoFile !== undefined)
232232
testInfoContent = fs.readFileSync(config.testInfoFile).toString();
233233
if (config.testInfo !== undefined)
234-
testInfoContent = config.testInfo.toString();
234+
testInfoContent = JSON.stringify(config.testInfo);
235235
if (config.testExecInfoFile !== undefined)
236236
testExecInfoContent = fs
237237
.readFileSync(config.testExecInfoFile)
238238
.toString();
239-
else testExecInfoContent = config.testExecInfo.toString();
239+
else testExecInfoContent = JSON.stringify(config.testExecInfo);
240240
} catch (error: any) {
241241
throw new XrayErrorResponse(error.message);
242242
}

0 commit comments

Comments
 (0)