mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
chore(server): remove unused code (#30772)
chore(server): remove unnused code
This commit is contained in:
parent
6a61901e79
commit
14241ac7bc
23 changed files with 5 additions and 328 deletions
13
server/test/fixtures/auth.stub.ts
vendored
13
server/test/fixtures/auth.stub.ts
vendored
|
|
@ -28,19 +28,6 @@ export const authStub = {
|
|||
id: 'token-id',
|
||||
} as AuthSession,
|
||||
}),
|
||||
user2: Object.freeze<AuthDto>({
|
||||
user: {
|
||||
id: 'user-2',
|
||||
name: 'User 2',
|
||||
email: 'user2@immich.cloud',
|
||||
isAdmin: false,
|
||||
quotaSizeInBytes: null,
|
||||
quotaUsageInBytes: 0,
|
||||
},
|
||||
session: {
|
||||
id: 'token-id',
|
||||
} as AuthSession,
|
||||
}),
|
||||
adminWithElevatedPermission: Object.freeze<AuthDto>({
|
||||
user: authUser.admin,
|
||||
session: {
|
||||
|
|
|
|||
7
server/test/fixtures/file.stub.ts
vendored
7
server/test/fixtures/file.stub.ts
vendored
|
|
@ -6,13 +6,6 @@ export const fileStub = {
|
|||
originalName: 'asset_1.jpeg',
|
||||
size: 42,
|
||||
}),
|
||||
livePhotoMotion: Object.freeze({
|
||||
uuid: 'live-photo-motion-asset',
|
||||
originalPath: 'fake_path/asset_1.mp4',
|
||||
checksum: Buffer.from('live photo file hash', 'utf8'),
|
||||
originalName: 'asset_1.mp4',
|
||||
size: 69,
|
||||
}),
|
||||
photo: Object.freeze({
|
||||
uuid: 'photo',
|
||||
originalPath: 'fake_path/photo1.jpeg',
|
||||
|
|
|
|||
22
server/test/fixtures/media.stub.ts
vendored
22
server/test/fixtures/media.stub.ts
vendored
|
|
@ -451,28 +451,6 @@ export const videoInfoStub = {
|
|||
},
|
||||
],
|
||||
}),
|
||||
videoStreamWithProfileLevel: Object.freeze<VideoInfo>({
|
||||
...probeStubDefault,
|
||||
videoStreams: [
|
||||
{
|
||||
...probeStubDefaultVideoStream[0],
|
||||
codecName: 'h264',
|
||||
profile: 100,
|
||||
level: 40,
|
||||
},
|
||||
],
|
||||
}),
|
||||
audioStreamAAC: Object.freeze<VideoInfo>({
|
||||
...probeStubDefault,
|
||||
audioStreams: [
|
||||
{
|
||||
index: 1,
|
||||
codecName: 'aac',
|
||||
profile: 2,
|
||||
bitrate: 128_000,
|
||||
},
|
||||
],
|
||||
}),
|
||||
};
|
||||
|
||||
interface SelectedStreams {
|
||||
|
|
|
|||
|
|
@ -1,27 +1,6 @@
|
|||
import { expect } from 'vitest';
|
||||
|
||||
export const errorDto = {
|
||||
unauthorized: {
|
||||
message: 'Authentication required',
|
||||
},
|
||||
forbidden: {
|
||||
message: expect.any(String),
|
||||
},
|
||||
missingPermission: (permission: string) => ({
|
||||
message: `Missing required permission: ${permission}`,
|
||||
}),
|
||||
wrongPassword: {
|
||||
message: 'Wrong password',
|
||||
},
|
||||
invalidToken: {
|
||||
message: 'Invalid user token',
|
||||
},
|
||||
invalidShareKey: {
|
||||
message: 'Invalid share key',
|
||||
},
|
||||
invalidSharePassword: {
|
||||
message: 'Invalid password',
|
||||
},
|
||||
badRequest: (message: any = null) => ({
|
||||
message: message ?? expect.anything(),
|
||||
}),
|
||||
|
|
@ -29,10 +8,4 @@ export const errorDto = {
|
|||
message: 'Validation failed',
|
||||
errors: errors ? expect.arrayContaining(errors.map((e) => expect.objectContaining(e))) : expect.any(Array),
|
||||
}),
|
||||
noPermission: {
|
||||
message: expect.stringContaining('Not found or no'),
|
||||
},
|
||||
incorrectLogin: {
|
||||
message: 'Incorrect email or password',
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { AuthApiKey, AuthSharedLink, AuthUser, Exif, Library, UserAdmin } from 'src/database';
|
||||
import { AuthApiKey, AuthSharedLink, AuthUser, Library, UserAdmin } from 'src/database';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { QueueStatisticsDto } from 'src/dtos/queue.dto';
|
||||
import { AssetFileType, Permission, UserStatus } from 'src/enum';
|
||||
import { Permission, UserStatus } from 'src/enum';
|
||||
import { v4, v7 } from 'uuid';
|
||||
import { expect } from 'vitest';
|
||||
|
||||
|
|
@ -168,31 +168,6 @@ const versionHistoryFactory = () => ({
|
|||
version: '1.123.45',
|
||||
});
|
||||
|
||||
const assetSidecarWriteFactory = () => {
|
||||
const id = newUuid();
|
||||
return {
|
||||
id,
|
||||
originalPath: '/path/to/original-path.jpg.xmp',
|
||||
tags: [],
|
||||
files: [
|
||||
{
|
||||
id: newUuid(),
|
||||
path: '/path/to/original-path.jpg.xmp',
|
||||
type: AssetFileType.Sidecar,
|
||||
isEdited: false,
|
||||
},
|
||||
],
|
||||
exifInfo: {
|
||||
assetId: id,
|
||||
description: 'this is a description',
|
||||
latitude: 12,
|
||||
longitude: 12,
|
||||
dateTimeOriginal: '2023-11-22T04:56:12.196Z',
|
||||
timeZone: 'UTC-6',
|
||||
} as unknown as Exif,
|
||||
};
|
||||
};
|
||||
|
||||
const assetOcrFactory = (
|
||||
ocr: {
|
||||
id?: string;
|
||||
|
|
@ -236,9 +211,6 @@ export const factory = {
|
|||
library: libraryFactory,
|
||||
queueStatistics: queueStatisticsFactory,
|
||||
versionHistory: versionHistoryFactory,
|
||||
jobAssets: {
|
||||
sidecarWrite: assetSidecarWriteFactory,
|
||||
},
|
||||
uuid: newUuid,
|
||||
buffer: () => Buffer.from('this is a fake buffer'),
|
||||
date: newDate,
|
||||
|
|
|
|||
|
|
@ -553,43 +553,6 @@ export const mockDuplex =
|
|||
return duplex;
|
||||
};
|
||||
|
||||
export const mockFork = vitest.fn((exitCode: number, stdout: string, stderr: string, error?: unknown) => {
|
||||
const stdoutStream = new Readable({
|
||||
read() {
|
||||
this.push(stdout); // write mock data to stdout
|
||||
this.push(null); // end stream
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
stdout: stdoutStream,
|
||||
stderr: new Readable({
|
||||
read() {
|
||||
this.push(stderr); // write mock data to stderr
|
||||
this.push(null); // end stream
|
||||
},
|
||||
}),
|
||||
stdin: new Writable({
|
||||
write(chunk, encoding, callback) {
|
||||
callback();
|
||||
},
|
||||
}),
|
||||
exitCode,
|
||||
on: vitest.fn((event, callback: any) => {
|
||||
if (event === 'close') {
|
||||
stdoutStream.once('end', () => callback(0));
|
||||
}
|
||||
if (event === 'error' && error) {
|
||||
stdoutStream.once('end', () => callback(error));
|
||||
}
|
||||
if (event === 'exit') {
|
||||
stdoutStream.once('end', () => callback(exitCode));
|
||||
}
|
||||
}),
|
||||
kill: vitest.fn(),
|
||||
} as unknown as ChildProcessWithoutNullStreams;
|
||||
});
|
||||
|
||||
export async function* makeStream<T>(items: T[] = []): AsyncGenerator<T> {
|
||||
for (const item of items) {
|
||||
await Promise.resolve();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue