fix tests

This commit is contained in:
Peter Clement 2024-03-14 13:13:11 +00:00
parent 9e2cc931df
commit d4b162add0
3 changed files with 11 additions and 8 deletions

View File

@ -152,7 +152,9 @@ class RestIntegration implements IntegrationBase {
contentType.includes("text/xml") || contentType.includes("text/xml") ||
contentType.includes("application/xml") contentType.includes("application/xml")
) { ) {
raw = handleXml(response) let xmlResponse = await handleXml(response)
data = xmlResponse.data
raw = xmlResponse.rawXml
} else { } else {
data = await response.text() data = await response.text()
raw = data raw = data

View File

@ -21,6 +21,7 @@ jest.mock("@budibase/backend-core", () => {
...core.objectStore, ...core.objectStore,
ObjectStoreBuckets: { ObjectStoreBuckets: {
APPS: "apps", APPS: "apps",
TEMP: "tmp-file-attachments",
}, },
upload: jest.fn(), upload: jest.fn(),
getPresignedUrl: jest.fn(() => "https://presigned-url.com"), getPresignedUrl: jest.fn(() => "https://presigned-url.com"),
@ -662,17 +663,17 @@ describe("REST Integration", () => {
const response = await config.integration.read(query) const response = await config.integration.read(query)
expect(objectStore.upload).toHaveBeenCalledWith({ expect(objectStore.upload).toHaveBeenCalledWith({
bucket: objectStore.ObjectStoreBuckets.APPS, bucket: objectStore.ObjectStoreBuckets.TEMP,
filename: expect.stringContaining( filename: expect.stringContaining(
"app-id/attachments/00000000-0000-0000-0000-000000000000.tar.gz" "app-id/00000000-0000-0000-0000-000000000000.tar.gz"
), ),
ttl: 1800, addTTL: true,
body: responseData, body: responseData,
}) })
expect(objectStore.getPresignedUrl).toHaveBeenCalledWith( expect(objectStore.getPresignedUrl).toHaveBeenCalledWith(
"test", objectStore.ObjectStoreBuckets.TEMP,
expect.stringContaining(`app-id/attachments/`), expect.stringContaining(`app-id/`),
600 600
) )
@ -681,7 +682,7 @@ describe("REST Integration", () => {
name: expect.stringContaining(".tar.gz"), name: expect.stringContaining(".tar.gz"),
url: "https://presigned-url.com", url: "https://presigned-url.com",
extension: "tar.gz", extension: "tar.gz",
key: expect.stringContaining(`app-id/attachments/`), key: expect.stringContaining(`app-id/`),
}) })
}) })
}) })

View File

@ -460,7 +460,7 @@ export async function handleXml(response: any) {
if (keys.length === 1 && Array.isArray(data[keys[0]])) { if (keys.length === 1 && Array.isArray(data[keys[0]])) {
data = data[keys[0]] data = data[keys[0]]
} }
return rawXml return { data, rawXml }
} }
export async function handleFileResponse( export async function handleFileResponse(