summary refs log tree commit diff
path: root/cdn/tests/filestorage.test.js
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-30 12:15:07 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-30 12:15:07 +0200
commit7847f55ef652887bd58e8599834d5b3418d81e93 (patch)
treed3a4651560c9c42b40952b6238c91097de7260ed /cdn/tests/filestorage.test.js
parent:construction: typeorm (diff)
parentadded unittests for filestorage [cdn] (diff)
downloadserver-7847f55ef652887bd58e8599834d5b3418d81e93.tar.xz
Merge branch 'typeorm' of https://github.com/fosscord/fosscord-api into typeorm
Diffstat (limited to '')
-rw-r--r--cdn/tests/filestorage.test.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/cdn/tests/filestorage.test.js b/cdn/tests/filestorage.test.js
new file mode 100644

index 00000000..78036602 --- /dev/null +++ b/cdn/tests/filestorage.test.js
@@ -0,0 +1,27 @@ +const path = require("path"); +process.env.STORAGE_LOCATION = path.join(__dirname, "..", "files", "/"); + +const { FileStorage } = require("../dist/util/FileStorage"); +const storage = new FileStorage(); +const fs = require("fs"); + +const file = fs.readFileSync(path.join(__dirname, "antman.jpg")); + +describe("FileStorage", () => { + describe("saving a file", () => { + test("saving a buffer", async () => { + await storage.set("test_saving_file", file); + }); + }); + describe("getting a file", () => { + test("getting buffer with given name", async () => { + const buffer2 = await storage.get("test_saving_file"); + expect(Buffer.compare(file, buffer2)).toBeTruthy(); + }); + }); + describe("deleting a file", () => { + test("deleting buffer with given name", async () => { + await storage.delete("test_saving_file"); + }); + }); +});