From 0a0cdac9a1501bca1b25af4d04796513a5ed7ecf Mon Sep 17 00:00:00 2001 From: ddingmin Date: Sun, 2 Jun 2024 23:36:59 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=EA=B9=A8=EC=A7=84=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/usecase/CreateNewMemberTest.kt | 49 +++++++++++++------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/src/test/kotlin/com/depromeet/makers/domain/usecase/CreateNewMemberTest.kt b/src/test/kotlin/com/depromeet/makers/domain/usecase/CreateNewMemberTest.kt index defddfa..2008143 100644 --- a/src/test/kotlin/com/depromeet/makers/domain/usecase/CreateNewMemberTest.kt +++ b/src/test/kotlin/com/depromeet/makers/domain/usecase/CreateNewMemberTest.kt @@ -1,7 +1,9 @@ package com.depromeet.makers.domain.usecase import com.depromeet.makers.domain.exception.MemberAlreadyExistsException +import com.depromeet.makers.domain.gateway.AttendanceGateway import com.depromeet.makers.domain.gateway.MemberGateway +import com.depromeet.makers.domain.gateway.SessionGateway import com.depromeet.makers.domain.model.Member import com.depromeet.makers.domain.model.MemberGeneration import com.depromeet.makers.domain.model.MemberPosition @@ -15,22 +17,26 @@ import io.mockk.every import io.mockk.mockk -class CreateNewMemberTest: BehaviorSpec({ +class CreateNewMemberTest : BehaviorSpec({ Given("이미 존재하는 이메일의 사용자이지만 새로운 기수일 때") { val memberGateway = mockk() - val createNewMember = CreateNewMember(memberGateway) + val sessionGateway = mockk() + val attendanceGateway = mockk() + val createNewMember = CreateNewMember(memberGateway, sessionGateway, attendanceGateway) val mockName = "송영민" val mockMemberId = "1" val mockEmail = "yeongmin1061@gmail.com" val mockGenerationId = 14 val mockPreviousGenerationId = 12 - val mockPreviousGenerations = setOf(MemberGeneration( - generationId = mockPreviousGenerationId, - role = MemberRole.MEMBER, - position = MemberPosition.BACKEND, - groupId = null, - )) + val mockPreviousGenerations = setOf( + MemberGeneration( + generationId = mockPreviousGenerationId, + role = MemberRole.MEMBER, + position = MemberPosition.BACKEND, + groupId = null, + ) + ) every { memberGateway.findByEmail(any()) } answers { val email = firstArg() @@ -43,6 +49,9 @@ class CreateNewMemberTest: BehaviorSpec({ ) } every { memberGateway.save(any()) } returnsArgument 0 + every { sessionGateway.findAllByGeneration(any()) } returns emptyList() + every { attendanceGateway.save(any()) } returns mockk() + When("execute가 실행하면") { val result = createNewMember.execute( @@ -69,19 +78,23 @@ class CreateNewMemberTest: BehaviorSpec({ Given("이미 존재하는 이메일의 사용자이고 이미 등록된 기수일 때") { val memberGateway = mockk() - val createNewMember = CreateNewMember(memberGateway) + val sessionGateway = mockk() + val attendanceGateway = mockk() + val createNewMember = CreateNewMember(memberGateway, sessionGateway, attendanceGateway) val mockName = "송영민" val mockMemberId = "1" val mockEmail = "yeongmin1061@gmail.com" val mockGenerationId = 14 val mockPreviousGenerationId = 14 - val mockPreviousGenerations = setOf(MemberGeneration( - generationId = mockPreviousGenerationId, - role = MemberRole.MEMBER, - position = MemberPosition.BACKEND, - groupId = null, - )) + val mockPreviousGenerations = setOf( + MemberGeneration( + generationId = mockPreviousGenerationId, + role = MemberRole.MEMBER, + position = MemberPosition.BACKEND, + groupId = null, + ) + ) every { memberGateway.findByEmail(any()) } answers { val email = firstArg() @@ -116,7 +129,9 @@ class CreateNewMemberTest: BehaviorSpec({ Given("처음 등록하는 사용자일 때") { val memberGateway = mockk() - val createNewMember = CreateNewMember(memberGateway) + val sessionGateway = mockk() + val attendanceGateway = mockk() + val createNewMember = CreateNewMember(memberGateway, sessionGateway, attendanceGateway) val mockName = "송영민" val mockEmail = "yeongmin1061@gmail.com" @@ -124,6 +139,8 @@ class CreateNewMemberTest: BehaviorSpec({ every { memberGateway.findByEmail(any()) } returns null every { memberGateway.save(any()) } returnsArgument 0 + every { sessionGateway.findAllByGeneration(any()) } returns emptyList() + every { attendanceGateway.save(any()) } returns mockk() When("execute가 실행하면") { val result = createNewMember.execute(