Skip to content

Commit a54c60d

Browse files
authored
BUG:Fix error in group update
1 parent a4e6e6b commit a54c60d

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/authorization/repository/group.repository.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Injectable } from '@nestjs/common';
2-
import { UpdateGroupInput } from 'src/schema/graphql.schema';
32
import { DataSource, In } from 'typeorm';
43
import Group from '../entity/group.entity';
54
import UserGroup from '../entity/userGroup.entity';
@@ -15,11 +14,8 @@ export class GroupRepository extends BaseRepository<Group> {
1514
return this.findOneBy({ id });
1615
}
1716

18-
async updateGroupById(
19-
id: string,
20-
updateGroupInput: UpdateGroupInput,
21-
): Promise<boolean> {
22-
const result = await this.update(id, updateGroupInput);
17+
async updateGroupById(id: string, name?: string): Promise<boolean> {
18+
const result = await this.update(id, { name });
2319

2420
return result.affected === 1;
2521
}

src/authorization/service/group.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ export class GroupService implements GroupServiceInterface {
123123
* @returns
124124
*/
125125
async updateGroup(id: string, group: UpdateGroupInput): Promise<Group> {
126-
const updatedGroup = await this.groupRepository.updateGroupById(id, group);
126+
const updatedGroup = await this.groupRepository.updateGroupById(
127+
id,
128+
group?.name,
129+
);
127130

128131
if (!updatedGroup) {
129132
throw new GroupNotFoundException(id);

src/config/migration.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { DataSource } from 'typeorm';
22
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
3-
3+
import dotenv from 'dotenv';
4+
dotenv.config();
45
/**
56
* Uses env params to configure TypeORM database library
67
*/

test/authorization/repository/group.repository.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('test Group repository', () => {
8080

8181
const result = await groupRepository.updateGroupById(
8282
VALID_GROUP_ID,
83-
updateGroupInput,
83+
updateGroupInput.name,
8484
);
8585

8686
expect(updateMock).toBeCalledWith(VALID_GROUP_ID, {

test/authorization/service/group.service.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ describe('test Group Service', () => {
277277

278278
expect(updateGroupByIdMock).toBeCalledWith(
279279
'ae032b1b-cc3c-4e44-9197-276ca877a7f8',
280-
input,
280+
input.name,
281281
);
282282
expect(getGroupByIdMock).toBeCalledWith(
283283
'ae032b1b-cc3c-4e44-9197-276ca877a7f8',
@@ -366,7 +366,7 @@ describe('test Group Service', () => {
366366
} catch (error) {
367367
expect(updateGroupByIdMock).toBeCalledWith(
368368
'ae032b1b-cc3c-4e44-9197-276ca877a7f9',
369-
input,
369+
input.name,
370370
);
371371
expect(getGroupByIdMock).not.toBeCalled();
372372

0 commit comments

Comments
 (0)