From 1beaac8e2ddffba236c8763de5aa76c1acdea5b1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 5 Sep 2023 17:02:14 +0900 Subject: [PATCH] fixes --- .../backend/src/core/NotificationService.ts | 2 +- packages/backend/test/unit/S3Service.ts | 12 ++-- packages/backend/test/unit/activitypub.ts | 12 ++-- packages/backend/test/unit/chart.ts | 2 +- .../test/unit/misc/correct-filename.ts | 72 +++++++++---------- packages/backend/test/utils.ts | 2 +- 6 files changed, 51 insertions(+), 51 deletions(-) diff --git a/packages/backend/src/core/NotificationService.ts b/packages/backend/src/core/NotificationService.ts index aa4e22f893..a3ce7d32a4 100644 --- a/packages/backend/src/core/NotificationService.ts +++ b/packages/backend/src/core/NotificationService.ts @@ -17,7 +17,7 @@ import { PushNotificationService } from '@/core/PushNotificationService.js'; import { NotificationEntityService } from '@/core/entities/NotificationEntityService.js'; import { IdService } from '@/core/IdService.js'; import { CacheService } from '@/core/CacheService.js'; -import { Config } from '@/config.js'; +import type { Config } from '@/config.js'; @Injectable() export class NotificationService implements OnApplicationShutdown { diff --git a/packages/backend/test/unit/S3Service.ts b/packages/backend/test/unit/S3Service.ts index eec8494322..94d8d83a0c 100644 --- a/packages/backend/test/unit/S3Service.ts +++ b/packages/backend/test/unit/S3Service.ts @@ -10,8 +10,8 @@ import { UploadPartCommand, CompleteMultipartUploadCommand, CreateMultipartUploa import { mockClient } from 'aws-sdk-client-mock'; import { GlobalModule } from '@/GlobalModule.js'; import { CoreModule } from '@/core/CoreModule.js'; -import { S3Service } from '@/core/S3Service'; -import { Meta } from '@/models'; +import { S3Service } from '@/core/S3Service.js'; +import { MiMeta } from '@/models/index.js'; import type { TestingModule } from '@nestjs/testing'; describe('S3Service', () => { @@ -40,7 +40,7 @@ describe('S3Service', () => { test('upload a file', async () => { s3Mock.on(PutObjectCommand).resolves({}); - await s3Service.upload({ objectStorageRegion: 'us-east-1' } as Meta, { + await s3Service.upload({ objectStorageRegion: 'us-east-1' } as MiMeta, { Bucket: 'fake', Key: 'fake', Body: 'x', @@ -52,7 +52,7 @@ describe('S3Service', () => { s3Mock.on(UploadPartCommand).resolves({ ETag: '1' }); s3Mock.on(CompleteMultipartUploadCommand).resolves({ Bucket: 'fake', Key: 'fake' }); - await s3Service.upload({} as Meta, { + await s3Service.upload({} as MiMeta, { Bucket: 'fake', Key: 'fake', Body: 'x'.repeat(8 * 1024 * 1024 + 1), // デフォルトpartSizeにしている 8 * 1024 * 1024 を越えるサイズ @@ -62,7 +62,7 @@ describe('S3Service', () => { test('upload a file error', async () => { s3Mock.on(PutObjectCommand).rejects({ name: 'Fake Error' }); - await expect(s3Service.upload({ objectStorageRegion: 'us-east-1' } as Meta, { + await expect(s3Service.upload({ objectStorageRegion: 'us-east-1' } as MiMeta, { Bucket: 'fake', Key: 'fake', Body: 'x', @@ -72,7 +72,7 @@ describe('S3Service', () => { test('upload a large file error', async () => { s3Mock.on(UploadPartCommand).rejects(); - await expect(s3Service.upload({} as Meta, { + await expect(s3Service.upload({} as MiMeta, { Bucket: 'fake', Key: 'fake', Body: 'x'.repeat(8 * 1024 * 1024 + 1), // デフォルトpartSizeにしている 8 * 1024 * 1024 を越えるサイズ diff --git a/packages/backend/test/unit/activitypub.ts b/packages/backend/test/unit/activitypub.ts index 73209523b5..a6e8409e0f 100644 --- a/packages/backend/test/unit/activitypub.ts +++ b/packages/backend/test/unit/activitypub.ts @@ -18,11 +18,11 @@ import { CoreModule } from '@/core/CoreModule.js'; import { FederatedInstanceService } from '@/core/FederatedInstanceService.js'; import { LoggerService } from '@/core/LoggerService.js'; import type { IActor, IApDocument, ICollection, IPost } from '@/core/activitypub/type.js'; -import { Meta, Note } from '@/models/index.js'; +import { MiMeta, MiNote } from '@/models/index.js'; import { secureRndstr } from '@/misc/secure-rndstr.js'; import { DownloadService } from '@/core/DownloadService.js'; import { MetaService } from '@/core/MetaService.js'; -import type { RemoteUser } from '@/models/entities/User.js'; +import type { MiRemoteUser } from '@/models/entities/User.js'; import { MockResolver } from '../misc/mock-resolver.js'; const host = 'https://host1.test'; @@ -75,7 +75,7 @@ function createRandomFeaturedCollection(actor: NonTransientIActor, length: numbe async function createRandomRemoteUser( resolver: MockResolver, personService: ApPersonService, -): Promise { +): Promise { const actor = createRandomActor(); resolver.register(actor.id, actor); @@ -94,7 +94,7 @@ describe('ActivityPub', () => { cacheRemoteSensitiveFiles: true, blockedHosts: [] as string[], sensitiveWords: [] as string[], - } as Meta; + } as MiMeta; let meta = metaInitial; beforeAll(async () => { @@ -109,7 +109,7 @@ describe('ActivityPub', () => { }, }) .overrideProvider(MetaService).useValue({ - async fetch(): Promise { + async fetch(): Promise { return meta; }, }).compile(); @@ -199,7 +199,7 @@ describe('ActivityPub', () => { rendererService.renderAnnounce(null, { createdAt: new Date(0), visibility: 'followers', - } as Note); + } as MiNote); }); }); diff --git a/packages/backend/test/unit/chart.ts b/packages/backend/test/unit/chart.ts index a419083e7d..036e73fd5e 100644 --- a/packages/backend/test/unit/chart.ts +++ b/packages/backend/test/unit/chart.ts @@ -18,7 +18,7 @@ import { entity as TestGroupedChartEntity } from '@/core/chart/charts/entities/t import { entity as TestUniqueChartEntity } from '@/core/chart/charts/entities/test-unique.js'; import { entity as TestIntersectionChartEntity } from '@/core/chart/charts/entities/test-intersection.js'; import { loadConfig } from '@/config.js'; -import type { AppLockService } from '@/core/AppLockService'; +import type { AppLockService } from '@/core/AppLockService.js'; import Logger from '@/logger.js'; describe('Chart', () => { diff --git a/packages/backend/test/unit/misc/correct-filename.ts b/packages/backend/test/unit/misc/correct-filename.ts index 8138b2361f..0c4482e0bf 100644 --- a/packages/backend/test/unit/misc/correct-filename.ts +++ b/packages/backend/test/unit/misc/correct-filename.ts @@ -6,42 +6,42 @@ import { correctFilename } from '@/misc/correct-filename.js'; describe(correctFilename, () => { - it('no ext to null', () => { - expect(correctFilename('test', null)).toBe('test.unknown'); - }); - it('no ext to jpg', () => { - expect(correctFilename('test', 'jpg')).toBe('test.jpg'); - }); - it('jpg to webp', () => { - expect(correctFilename('test.jpg', 'webp')).toBe('test.jpg.webp'); - }); - it('jpg to .webp', () => { - expect(correctFilename('test.jpg', '.webp')).toBe('test.jpg.webp'); - }); - it('jpeg to jpg', () => { - expect(correctFilename('test.jpeg', 'jpg')).toBe('test.jpeg'); - }); - it('JPEG to jpg', () => { - expect(correctFilename('test.JPEG', 'jpg')).toBe('test.JPEG'); - }); - it('jpg to jpg', () => { - expect(correctFilename('test.jpg', 'jpg')).toBe('test.jpg'); - }); - it('JPG to jpg', () => { - expect(correctFilename('test.JPG', 'jpg')).toBe('test.JPG'); - }); - it('tiff to tif', () => { - expect(correctFilename('test.tiff', 'tif')).toBe('test.tiff'); - }); - it('skip gz', () => { - expect(correctFilename('test.unitypackage', 'gz')).toBe('test.unitypackage'); - }); - it('skip text file', () => { - expect(correctFilename('test.txt', null)).toBe('test.txt'); - }); - it('unknown', () => { - expect(correctFilename('test.hoge', null)).toBe('test.hoge'); - }); + it('no ext to null', () => { + expect(correctFilename('test', null)).toBe('test.unknown'); + }); + it('no ext to jpg', () => { + expect(correctFilename('test', 'jpg')).toBe('test.jpg'); + }); + it('jpg to webp', () => { + expect(correctFilename('test.jpg', 'webp')).toBe('test.jpg.webp'); + }); + it('jpg to .webp', () => { + expect(correctFilename('test.jpg', '.webp')).toBe('test.jpg.webp'); + }); + it('jpeg to jpg', () => { + expect(correctFilename('test.jpeg', 'jpg')).toBe('test.jpeg'); + }); + it('JPEG to jpg', () => { + expect(correctFilename('test.JPEG', 'jpg')).toBe('test.JPEG'); + }); + it('jpg to jpg', () => { + expect(correctFilename('test.jpg', 'jpg')).toBe('test.jpg'); + }); + it('JPG to jpg', () => { + expect(correctFilename('test.JPG', 'jpg')).toBe('test.JPG'); + }); + it('tiff to tif', () => { + expect(correctFilename('test.tiff', 'tif')).toBe('test.tiff'); + }); + it('skip gz', () => { + expect(correctFilename('test.unitypackage', 'gz')).toBe('test.unitypackage'); + }); + it('skip text file', () => { + expect(correctFilename('test.txt', null)).toBe('test.txt'); + }); + it('unknown', () => { + expect(correctFilename('test.hoge', null)).toBe('test.hoge'); + }); test('non ascii with space', () => { expect(correctFilename('ファイル 名前', 'jpg')).toBe('ファイル 名前.jpg'); }); diff --git a/packages/backend/test/utils.ts b/packages/backend/test/utils.ts index 0a24a47066..adc532bbe7 100644 --- a/packages/backend/test/utils.ts +++ b/packages/backend/test/utils.ts @@ -8,7 +8,7 @@ import { readFile } from 'node:fs/promises'; import { isAbsolute, basename } from 'node:path'; import { inspect } from 'node:util'; import WebSocket, { ClientOptions } from 'ws'; -import fetch, { Blob, File, RequestInit } from 'node-fetch'; +import fetch, { File, RequestInit } from 'node-fetch'; import { DataSource } from 'typeorm'; import { JSDOM } from 'jsdom'; import { DEFAULT_POLICIES } from '@/core/RoleService.js';