mirror of https://github.com/usbharu/Hideout.git
test: fix test
This commit is contained in:
parent
7fff8e39d4
commit
3f830097ed
|
@ -10,6 +10,7 @@ import dev.usbharu.hideout.domain.model.hideout.entity.User
|
|||
import dev.usbharu.hideout.domain.model.hideout.entity.Visibility
|
||||
import dev.usbharu.hideout.domain.model.job.DeliverPostJob
|
||||
import dev.usbharu.hideout.query.FollowerQueryService
|
||||
import dev.usbharu.hideout.query.MediaQueryService
|
||||
import dev.usbharu.hideout.query.UserQueryService
|
||||
import dev.usbharu.hideout.service.job.JobQueueParentService
|
||||
import io.ktor.client.*
|
||||
|
@ -19,6 +20,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
|
|||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.Mockito.anyLong
|
||||
import org.mockito.Mockito.eq
|
||||
import org.mockito.kotlin.*
|
||||
import utils.JsonObjectMapper
|
||||
|
@ -29,7 +31,11 @@ import kotlin.test.assertEquals
|
|||
|
||||
class APNoteServiceImplTest {
|
||||
@Test
|
||||
fun `createPost 新しい投稿`() = runTest {
|
||||
fun `createPost 新しい投稿`() {
|
||||
val mediaQueryService = mock<MediaQueryService> {
|
||||
onBlocking { findByPostId(anyLong()) } doReturn emptyList()
|
||||
}
|
||||
runTest {
|
||||
val followers = listOf(
|
||||
User.of(
|
||||
2L,
|
||||
|
@ -90,6 +96,7 @@ class APNoteServiceImplTest {
|
|||
objectMapper = objectMapper,
|
||||
applicationConfig = testApplicationConfig,
|
||||
postService = mock(),
|
||||
mediaQueryService = mediaQueryService
|
||||
)
|
||||
val postEntity = Post.of(
|
||||
1L,
|
||||
|
@ -103,9 +110,14 @@ class APNoteServiceImplTest {
|
|||
activityPubNoteService.createNote(postEntity)
|
||||
verify(jobQueueParentService, times(2)).schedule(eq(DeliverPostJob), any())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `createPostJob 新しい投稿のJob`() = runTest {
|
||||
fun `createPostJob 新しい投稿のJob`() {
|
||||
runTest {
|
||||
val mediaQueryService = mock<MediaQueryService> {
|
||||
onBlocking { findByPostId(anyLong()) } doReturn emptyList()
|
||||
}
|
||||
Config.configData = ConfigData(objectMapper = JsonObjectMapper.objectMapper)
|
||||
val httpClient = HttpClient(
|
||||
MockEngine { httpRequestData ->
|
||||
|
@ -124,6 +136,7 @@ class APNoteServiceImplTest {
|
|||
objectMapper = objectMapper,
|
||||
applicationConfig = testApplicationConfig,
|
||||
postService = mock(),
|
||||
mediaQueryService = mediaQueryService
|
||||
)
|
||||
activityPubNoteService.createNoteJob(
|
||||
JobProps(
|
||||
|
@ -137,10 +150,12 @@ class APNoteServiceImplTest {
|
|||
"visibility": 0,
|
||||
"url": "https://example.com"
|
||||
}""",
|
||||
DeliverPostJob.inbox.name to "https://follower.example.com/inbox"
|
||||
DeliverPostJob.inbox.name to "https://follower.example.com/inbox",
|
||||
DeliverPostJob.media.name to "[]"
|
||||
),
|
||||
json = Json
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue