From 595698b7c95a9894e94b29def55fbd2a8fd739c5 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 7 May 2021 14:27:46 +0100 Subject: [PATCH] Fixing issue with object store functions not being mockable in the server. --- .../src/api/controllers/static/index.js | 2 +- .../server/src/utilities/fileSystem/index.js | 2 +- .../server/src/utilities/fileSystem/newApp.js | 2 +- .../src/utilities/fileSystem/utilities.js | 30 +++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 packages/server/src/utilities/fileSystem/utilities.js diff --git a/packages/server/src/api/controllers/static/index.js b/packages/server/src/api/controllers/static/index.js index 342677c6f9..7a6d6c7e39 100644 --- a/packages/server/src/api/controllers/static/index.js +++ b/packages/server/src/api/controllers/static/index.js @@ -4,7 +4,7 @@ const send = require("koa-send") const { resolve, join } = require("../../../utilities/centralPath") const fetch = require("node-fetch") const uuid = require("uuid") -const { ObjectStoreBuckets } = require("@budibase/auth").objectStore +const { ObjectStoreBuckets } = require("../../../constants") const { prepareUpload } = require("../deploy/utils") const { processString } = require("@budibase/string-templates") const { budibaseTempDir } = require("../../../utilities/budibaseDir") diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index 1b303b62fa..d84c6deb8a 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -12,7 +12,7 @@ const { streamUpload, deleteFolder, downloadTarball, -} = require("@budibase/auth").objectStore +} = require("./utilities") const { downloadLibraries, newAppPublicPath } = require("./newApp") const download = require("download") const env = require("../../environment") diff --git a/packages/server/src/utilities/fileSystem/newApp.js b/packages/server/src/utilities/fileSystem/newApp.js index 5c42b77f69..91cc771743 100644 --- a/packages/server/src/utilities/fileSystem/newApp.js +++ b/packages/server/src/utilities/fileSystem/newApp.js @@ -1,7 +1,7 @@ const packageJson = require("../../../package.json") const { join } = require("path") const { ObjectStoreBuckets } = require("../../constants") -const { streamUpload, downloadTarball } = require("@budibase/auth").objectStore +const { streamUpload, downloadTarball } = require("./utilities") const fs = require("fs") const BUCKET_NAME = ObjectStoreBuckets.APPS diff --git a/packages/server/src/utilities/fileSystem/utilities.js b/packages/server/src/utilities/fileSystem/utilities.js new file mode 100644 index 0000000000..c33ce083c1 --- /dev/null +++ b/packages/server/src/utilities/fileSystem/utilities.js @@ -0,0 +1,30 @@ +const { + ObjectStore, + makeSureBucketExists, + upload, + streamUpload, + retrieve, + retrieveToTmp, + deleteFolder, + uploadDirectory, + downloadTarball, +} = require("@budibase/auth").objectStore + +/*********************************** + * NOTE * + * This file purely exists so that * + * the object store functionality * + * can easily be mocked out of * + * the server without mocking the * + * entire core library. * + ***********************************/ + +exports.ObjectStore = ObjectStore +exports.makeSureBucketExists = makeSureBucketExists +exports.upload = upload +exports.streamUpload = streamUpload +exports.retrieve = retrieve +exports.retrieveToTmp = retrieveToTmp +exports.deleteFolder = deleteFolder +exports.uploadDirectory = uploadDirectory +exports.downloadTarball = downloadTarball