Skip to content

Commit

Permalink
test: add GetExperimentPostTotalCountByCustomFilterUseCaseTest test code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ji-soo708 committed Jan 20, 2025
1 parent 7370567 commit d4e00ea
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.dobby.backend.application.usecase.experiment

import com.dobby.backend.domain.gateway.experiment.ExperimentPostGateway
import com.dobby.backend.infrastructure.database.entity.enums.MatchType
import com.dobby.backend.infrastructure.database.entity.enums.experiment.RecruitStatus
import io.kotest.core.spec.style.BehaviorSpec
import io.kotest.matchers.shouldBe
import io.mockk.every
import io.mockk.mockk

class GetExperimentPostTotalCountByCustomFilterUseCaseTest : BehaviorSpec({
val experimentPostGateway = mockk<ExperimentPostGateway>()
val getExperimentPostTotalCountByCustomFilterUseCase = GetExperimentPostTotalCountByCustomFilterUseCase(experimentPostGateway)

given("유효한 필터 조건이 주어졌을 때") {
val input = GetExperimentPostTotalCountByCustomFilterUseCase.Input(
matchType = MatchType.ALL,
studyTarget = null,
locationTarget = null,
recruitStatus = RecruitStatus.ALL
)

every {
experimentPostGateway.countExperimentPostsByCustomFilter(any())
} returns 10

`when`("execute가 호출되면") {
val result = getExperimentPostTotalCountByCustomFilterUseCase.execute(input)

then("올바른 게시글 개수를 반환한다") {
result shouldBe 10
}
}
}

given("필터 조건에 맞는 게시글이 없을 때") {
val input = GetExperimentPostTotalCountByCustomFilterUseCase.Input(
matchType = MatchType.OFFLINE,
studyTarget = null,
locationTarget = null,
recruitStatus = RecruitStatus.OPEN
)

every {
experimentPostGateway.countExperimentPostsByCustomFilter(any())
} returns 0

`when`("execute가 호출되면") {
val result = getExperimentPostTotalCountByCustomFilterUseCase.execute(input)

then("게시글 개수가 0으로 반환된다") {
result shouldBe 0
}
}
}
})

0 comments on commit d4e00ea

Please sign in to comment.