From e668d1409a135c1e83b58d7afc4ef87462a0d0e6 Mon Sep 17 00:00:00 2001 From: stekrause Date: Tue, 19 Sep 2023 14:23:34 +0200 Subject: [PATCH] refactor imports of contentStorage and temporary file storage --- .../service/contentStorage.service.spec.ts | 6 +++--- .../temporary-file-storage.service.spec.ts | 15 ++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/server/src/modules/h5p-editor/service/contentStorage.service.spec.ts b/apps/server/src/modules/h5p-editor/service/contentStorage.service.spec.ts index e643d06bdcd..a1fa6cf1f98 100644 --- a/apps/server/src/modules/h5p-editor/service/contentStorage.service.spec.ts +++ b/apps/server/src/modules/h5p-editor/service/contentStorage.service.spec.ts @@ -4,8 +4,8 @@ import { IContentMetadata, ILibraryName, LibraryName } from '@lumieducation/h5p- import { InternalServerErrorException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { IEntity } from '@shared/domain'; -import { S3ClientAdapter } from '@src/modules/files-storage/client/s3-client.adapter'; -import { IGetFileResponse } from '@src/modules/files-storage/interface'; +import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { GetFileResponse } from '@src/modules/files-storage/interface'; import { ObjectID } from 'bson'; import { Readable } from 'stream'; import { H5PContent } from '../entity'; @@ -595,7 +595,7 @@ describe('ContentStorage', () => { const filename = 'testfile.txt'; const fileStream = Readable.from('content'); const contentID = new ObjectID().toString(); - const fileResponse = createMock({ data: fileStream }); + const fileResponse = createMock({ data: fileStream }); const user = helpers.createUser(); const getError = new Error('Could not get file'); diff --git a/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts b/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts index f5779b73ea4..234d744a2eb 100644 --- a/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts +++ b/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts @@ -2,9 +2,9 @@ import { ServiceOutputTypes } from '@aws-sdk/client-s3'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { IUser } from '@lumieducation/h5p-server'; import { Test, TestingModule } from '@nestjs/testing'; -import { S3ClientAdapter } from '@src/modules/files-storage/client/s3-client.adapter'; +import { S3ClientAdapter } from '@shared/infra/s3-client'; import { FileDto } from '@src/modules/files-storage/dto'; -import { IGetFileResponse } from '@src/modules/files-storage/interface'; +import { GetFileResponse } from '@src/modules/files-storage/interface'; import { ReadStream } from 'fs'; import { join } from 'node:path'; import { Readable } from 'node:stream'; @@ -182,14 +182,15 @@ describe('TemporaryFileStorage', () => { it('should return readable file stream', async () => { const { user1, file1 } = setup(); const actualContent = fileContent(user1.id, file1.filename); - const response: Required = { + const response: Required = { data: Readable.from(actualContent), - contentType: undefined, - contentLength: undefined, - contentRange: undefined, - etag: undefined, + etag: '', + contentType: '', + contentLength: 0, + contentRange: '', name: '', }; + repo.findByUserAndFilename.mockResolvedValueOnce(file1); s3clientAdapter.get.mockResolvedValueOnce(response);