Fixing a test case.

This commit is contained in:
mike12345567 2024-05-24 12:40:58 +01:00
parent 62c407d846
commit ae26f66cf9
2 changed files with 8 additions and 8 deletions

View File

@ -64,13 +64,11 @@ describe("rest", () => {
cached = await getCachedVariable(basedOnQuery._id!, "foo") cached = await getCachedVariable(basedOnQuery._id!, "foo")
expect(cached).toBeNull() expect(cached).toBeNull()
nock("http://one.example.com") const body1 = [{ name: "one" }]
.get("/") const body2 = [{ name: "two" }]
.reply(200, [{ name: "one" }]) nock("http://one.example.com").get("/").reply(200, body1)
nock("http://two.example.com").get("/?test=one").reply(500) nock("http://two.example.com").get("/?test=one").reply(500)
nock("http://two.example.com") nock("http://two.example.com").get("/?test=one").reply(200, body2)
.get("/?test=one")
.reply(200, [{ name: "two" }])
const res = await config.api.query.preview({ const res = await config.api.query.preview({
datasourceId: datasource._id!, datasourceId: datasource._id!,

View File

@ -163,12 +163,14 @@ class RestIntegration implements IntegrationBase {
let triedParsing: boolean = false, let triedParsing: boolean = false,
responseTxt: string | undefined responseTxt: string | undefined
const hasContent = contentLength && parseInt(contentLength) > 0
try { try {
if (filename) { if (filename) {
return handleFileResponse(response, filename, this.startTimeMs) return handleFileResponse(response, filename, this.startTimeMs)
} else { } else {
responseTxt = hasContent && response.text ? await response.text() : "" responseTxt = response.text ? await response.text() : ""
const hasContent =
(contentLength && parseInt(contentLength) > 0) ||
responseTxt.length > 0
if (response.status === 204) { if (response.status === 204) {
data = [] data = []
raw = "" raw = ""