Skip to content

Commit

Permalink
test: 깨진 테스트 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ddingmin committed Jun 2, 2024
1 parent a287468 commit 0a0cdac
Showing 1 changed file with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,22 +17,26 @@ import io.mockk.every
import io.mockk.mockk


class CreateNewMemberTest: BehaviorSpec({
class CreateNewMemberTest : BehaviorSpec({
Given("이미 존재하는 이메일의 사용자이지만 새로운 기수일 때") {
val memberGateway = mockk<MemberGateway>()
val createNewMember = CreateNewMember(memberGateway)
val sessionGateway = mockk<SessionGateway>()
val attendanceGateway = mockk<AttendanceGateway>()
val createNewMember = CreateNewMember(memberGateway, sessionGateway, attendanceGateway)

val mockName = "송영민"
val mockMemberId = "1"
val mockEmail = "[email protected]"
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<String>()
Expand All @@ -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(
Expand All @@ -69,19 +78,23 @@ class CreateNewMemberTest: BehaviorSpec({

Given("이미 존재하는 이메일의 사용자이고 이미 등록된 기수일 때") {
val memberGateway = mockk<MemberGateway>()
val createNewMember = CreateNewMember(memberGateway)
val sessionGateway = mockk<SessionGateway>()
val attendanceGateway = mockk<AttendanceGateway>()
val createNewMember = CreateNewMember(memberGateway, sessionGateway, attendanceGateway)

val mockName = "송영민"
val mockMemberId = "1"
val mockEmail = "[email protected]"
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<String>()
Expand Down Expand Up @@ -116,14 +129,18 @@ class CreateNewMemberTest: BehaviorSpec({

Given("처음 등록하는 사용자일 때") {
val memberGateway = mockk<MemberGateway>()
val createNewMember = CreateNewMember(memberGateway)
val sessionGateway = mockk<SessionGateway>()
val attendanceGateway = mockk<AttendanceGateway>()
val createNewMember = CreateNewMember(memberGateway, sessionGateway, attendanceGateway)

val mockName = "송영민"
val mockEmail = "[email protected]"
val mockGenerationId = 14

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(
Expand Down

0 comments on commit 0a0cdac

Please sign in to comment.