From ff568fddadc081298b04af528952801c1ce382d2 Mon Sep 17 00:00:00 2001 From: foxriver76 Date: Wed, 8 Jan 2025 16:14:07 +0100 Subject: [PATCH] fix tests now --- packages/controller/test/lib/testFiles.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/controller/test/lib/testFiles.ts b/packages/controller/test/lib/testFiles.ts index 72f871096..5c606428c 100644 --- a/packages/controller/test/lib/testFiles.ts +++ b/packages/controller/test/lib/testFiles.ts @@ -1,5 +1,4 @@ import type { TestContext } from '../_Types.js'; -import { objectsUtils as utils } from '@iobroker/db-objects-redis'; export function register(it: Mocha.TestFunction, expect: Chai.ExpectStatic, context: TestContext): void { const testName = `${context.name} ${context.adapterShortName} files: `; @@ -10,7 +9,7 @@ export function register(it: Mocha.TestFunction, expect: Chai.ExpectStatic, cont const fileName = 'testFile.bin'; const dataBinary = Buffer.from('1234'); // create an object of type file first - await context.adapter.setForeignObjectAsync(objId, { + await context.adapter.setForeignObject(objId, { type: 'meta', common: { name: 'Files and more', @@ -226,7 +225,13 @@ export function register(it: Mocha.TestFunction, expect: Chai.ExpectStatic, cont it(`${testName}should read empty directory`, async () => { const objects = context.objects; - const id = `${testId}.files`; + const id = `${testId}.meta.files`; + + await objects.setObject(id, { + type: 'meta', + common: { name: 'test', type: 'meta.user' }, + native: {}, + }); const res = await objects.readDirAsync(id, ''); expect(res).to.be.empty; @@ -234,18 +239,19 @@ export function register(it: Mocha.TestFunction, expect: Chai.ExpectStatic, cont it(`${testName}should read empty directory with path`, async () => { const objects = context.objects; - const id = `${testId}.files`; + const id = `${testId}.meta.files`; const res = await objects.readDirAsync(id, 'random/path'); expect(res).to.be.empty; }); - it(`${testName}should respond with 'ERROR_NOT_FOUND' if calling readDir on a single file`, async () => { + it(`${testName}should respond with empty array if calling readDir on a single file`, async () => { const objects = context.objects; const fileName = 'dir/notADir.txt'; await objects.writeFileAsync(testId, fileName, 'dataInFile'); - expect(objects.readDirAsync(testId, fileName)).to.be.eventually.rejectedWith(utils.ERRORS.ERROR_NOT_FOUND); + const res = await objects.readDirAsync(testId, fileName); + expect(res).to.be.empty; }); it(`${testName}should read file and prevent path traversing`, done => {