Skip to content

Commit

Permalink
refactor imports of contentStorage and temporary file storage
Browse files Browse the repository at this point in the history
  • Loading branch information
SteKrause committed Sep 19, 2023
1 parent 07e2cd6 commit e668d14
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -595,7 +595,7 @@ describe('ContentStorage', () => {
const filename = 'testfile.txt';
const fileStream = Readable.from('content');
const contentID = new ObjectID().toString();
const fileResponse = createMock<IGetFileResponse>({ data: fileStream });
const fileResponse = createMock<GetFileResponse>({ data: fileStream });
const user = helpers.createUser();

const getError = new Error('Could not get file');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<IGetFileResponse> = {
const response: Required<GetFileResponse> = {
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);

Expand Down

0 comments on commit e668d14

Please sign in to comment.