This commit is contained in:
syuilo 2023-09-05 17:02:14 +09:00
parent 2630513c83
commit 1beaac8e2d
6 changed files with 51 additions and 51 deletions

View File

@ -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 {

View File

@ -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 を越えるサイズ

View File

@ -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<RemoteUser> {
): Promise<MiRemoteUser> {
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<Meta> {
async fetch(): Promise<MiMeta> {
return meta;
},
}).compile();
@ -199,7 +199,7 @@ describe('ActivityPub', () => {
rendererService.renderAnnounce(null, {
createdAt: new Date(0),
visibility: 'followers',
} as Note);
} as MiNote);
});
});

View File

@ -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', () => {

View File

@ -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');
});

View File

@ -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';