test: APSendFollowServiceImplのテストを追加

This commit is contained in:
usbharu 2023-10-31 15:25:52 +09:00
parent aec68aaeba
commit d0b5cd411d
1 changed files with 36 additions and 0 deletions

View File

@ -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)
)
}
}