refactor: migration tag repository to kysely (#16398)

This commit is contained in:
Jason Rasmussen
2025-03-03 13:41:19 -05:00
committed by GitHub
parent ff19502035
commit d1fd0076cc
12 changed files with 343 additions and 245 deletions

View File

@@ -1,49 +1,51 @@
import { TagResponseDto } from 'src/dtos/tag.dto';
import { TagEntity } from 'src/entities/tag.entity';
import { userStub } from 'test/fixtures/user.stub';
import { TagItem } from 'src/types';
const parent = Object.freeze<TagEntity>({
const parent = Object.freeze<TagItem>({
id: 'tag-parent',
createdAt: new Date('2021-01-01T00:00:00Z'),
updatedAt: new Date('2021-01-01T00:00:00Z'),
value: 'Parent',
color: null,
userId: userStub.admin.id,
user: userStub.admin,
parentId: null,
});
const child = Object.freeze<TagEntity>({
const child = Object.freeze<TagItem>({
id: 'tag-child',
createdAt: new Date('2021-01-01T00:00:00Z'),
updatedAt: new Date('2021-01-01T00:00:00Z'),
value: 'Parent/Child',
color: null,
parent,
userId: userStub.admin.id,
user: userStub.admin,
parentId: parent.id,
});
const tag = {
id: 'tag-1',
createdAt: new Date('2021-01-01T00:00:00Z'),
updatedAt: new Date('2021-01-01T00:00:00Z'),
value: 'Tag1',
color: null,
parentId: null,
};
const color = {
id: 'tag-1',
createdAt: new Date('2021-01-01T00:00:00Z'),
updatedAt: new Date('2021-01-01T00:00:00Z'),
value: 'Tag1',
color: '#000000',
parentId: null,
};
const upsert = { userId: 'tag-user', updateId: 'uuid-v7' };
export const tagStub = {
tag1: Object.freeze<TagEntity>({
id: 'tag-1',
createdAt: new Date('2021-01-01T00:00:00Z'),
updatedAt: new Date('2021-01-01T00:00:00Z'),
value: 'Tag1',
color: null,
userId: userStub.admin.id,
user: userStub.admin,
}),
parent,
child,
color1: Object.freeze<TagEntity>({
id: 'tag-1',
createdAt: new Date('2021-01-01T00:00:00Z'),
updatedAt: new Date('2021-01-01T00:00:00Z'),
value: 'Tag1',
color: '#000000',
userId: userStub.admin.id,
user: userStub.admin,
}),
tag,
tagCreate: { ...tag, ...upsert },
color,
colorCreate: { ...color, ...upsert },
parentUpsert: { ...parent, ...upsert },
childUpsert: { ...child, ...upsert },
};
export const tagResponseStub = {

View File

@@ -7,7 +7,7 @@ export const newTagRepositoryMock = (): Mocked<RepositoryInterface<TagRepository
getAll: vitest.fn(),
getByValue: vitest.fn(),
upsertValue: vitest.fn(),
upsertAssetTags: vitest.fn(),
replaceAssetTags: vitest.fn(),
get: vitest.fn(),
create: vitest.fn(),