From 2182a17147a64b84ef79bf6071248fd5364761c5 Mon Sep 17 00:00:00 2001 From: Zhongwen Lian Date: Fri, 17 Feb 2023 14:56:21 +0800 Subject: [PATCH] feat(backend): fix unittest bug --- .../rest/applicationservice/ProjectApplicationService.kt | 1 + .../rest/applicationservice/ProjectApplicationServiceTest.kt | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/main/kotlin/metrik/project/rest/applicationservice/ProjectApplicationService.kt b/backend/src/main/kotlin/metrik/project/rest/applicationservice/ProjectApplicationService.kt index 0b18b2b0..1cc61360 100644 --- a/backend/src/main/kotlin/metrik/project/rest/applicationservice/ProjectApplicationService.kt +++ b/backend/src/main/kotlin/metrik/project/rest/applicationservice/ProjectApplicationService.kt @@ -46,6 +46,7 @@ class ProjectApplicationService { fun updateProjectName(projectId: String, updateProjectRequest: UpdateProjectRequest): ProjectResponse { val projectName = updateProjectRequest.projectName + verifyProjectNameNotDuplicate(projectName) val project = projectRepository.findById(projectId) project.name = projectName return ProjectResponse(projectRepository.save(project)) diff --git a/backend/src/test/kotlin/metrik/project/rest/applicationservice/ProjectApplicationServiceTest.kt b/backend/src/test/kotlin/metrik/project/rest/applicationservice/ProjectApplicationServiceTest.kt index 3d4af707..c026994a 100644 --- a/backend/src/test/kotlin/metrik/project/rest/applicationservice/ProjectApplicationServiceTest.kt +++ b/backend/src/test/kotlin/metrik/project/rest/applicationservice/ProjectApplicationServiceTest.kt @@ -105,10 +105,10 @@ internal class ProjectApplicationServiceTest { @Test fun `update project will fail if project name already exist`() { - val newProjectName = "new project name" + val newProjectName = UpdateProjectRequest("new project name") every { projectRepository.findById(projectId) } returns expectedProject every { projectRepository.save(expectedProject) } returns expectedProject - every { projectRepository.existWithGivenName(newProjectName) } returns true + every { projectRepository.existWithGivenName(newProjectName.projectName) } returns true val exception = assertThrows { projectApplicationService.updateProjectName(projectId, newProjectName)