mirror of https://github.com/usbharu/Hideout.git
test: APSendFollowServiceImplのテストを追加
This commit is contained in:
parent
aec68aaeba
commit
d0b5cd411d
|
@ -0,0 +1,36 @@
|
|||
package dev.usbharu.hideout.service.ap
|
||||
|
||||
import dev.usbharu.hideout.domain.model.ap.Follow
|
||||
import dev.usbharu.hideout.domain.model.hideout.dto.SendFollowDto
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.kotlin.eq
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.times
|
||||
import org.mockito.kotlin.verify
|
||||
import utils.UserBuilder
|
||||
|
||||
class APSendFollowServiceImplTest {
|
||||
@Test
|
||||
fun `sendFollow フォローするユーザーのinboxにFollowオブジェクトが送られる`() = runTest {
|
||||
val apRequestService = mock<APRequestService>()
|
||||
val apSendFollowServiceImpl = APSendFollowServiceImpl(apRequestService)
|
||||
|
||||
val sendFollowDto = SendFollowDto(
|
||||
UserBuilder.localUserOf(),
|
||||
UserBuilder.remoteUserOf()
|
||||
)
|
||||
apSendFollowServiceImpl.sendFollow(sendFollowDto)
|
||||
|
||||
val value = Follow(
|
||||
name = "Follow",
|
||||
`object` = sendFollowDto.followTargetUserId.url,
|
||||
actor = sendFollowDto.userId.url
|
||||
)
|
||||
verify(apRequestService, times(1)).apPost(
|
||||
eq(sendFollowDto.followTargetUserId.inbox),
|
||||
eq(value),
|
||||
eq(sendFollowDto.userId)
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue