Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/test/kotlin/dev/usbharu/multim/TestUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ object TestUtil {
): suspend MockRequestHandleScope.(HttpRequestData) -> HttpResponseData {
return { httpRequestData: HttpRequestData ->
val decodeToString = httpRequestData.body.toByteArray().decodeToString()
println(decodeToString)
Logger.debug(decodeToString)
if ("i" in json.parseToJsonElement(decodeToString).jsonObject) {
respond(respond, status, headers)
} else {
Expand Down
8 changes: 6 additions & 2 deletions core/src/test/kotlin/dev/usbharu/multim/api/NodeInfoTest.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package dev.usbharu.multim.api

import dev.usbharu.multim.Logger
import dev.usbharu.multim.TestUtil.failOnError
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.serialization.kotlinx.json.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.json.Json
import org.junit.jupiter.api.Test

class NodeInfoE2E {
@OptIn(ExperimentalCoroutinesApi::class)
@Test
fun nodeinfo() = runTest {
val nodeinfo = NodeinfoApi(HttpClient(CIO).config {
Expand All @@ -18,7 +22,7 @@ class NodeInfoE2E {
isLenient = true
})
}
}).nodeinfo(System.getProperty("multim_misskey_instance"))
println(nodeinfo)
}).nodeinfo(System.getProperty("multim_misskey_instance")).failOnError()
Logger.debug(nodeinfo.toString())
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.usbharu.multim.misskey.v12.common.api

import dev.usbharu.multim.Logger
import dev.usbharu.multim.MultiM.json
import dev.usbharu.multim.api.ApiClient
import dev.usbharu.multim.misskey.v12.model.components.MisskeyNeedAuth
Expand Down Expand Up @@ -27,9 +28,9 @@ class MisskeyApiClient(var auth: SingleTokenAuth, baseUrl: String, client: HttpC
}
install(createClientPlugin("MisskeyAuthPlugin") {
onRequest { request, content ->
println("request type is :${content::class}")
Logger.trace("Misskey Auth Plugin","request type is :${content::class}")
if (content is MisskeyNeedAuth) {
println("injection token")
Logger.trace("Misskey Auth Plugin","Injection token")
content.i = auth.token
}
request.headers.append(
Expand All @@ -54,7 +55,7 @@ class MisskeyApiClient(var auth: SingleTokenAuth, baseUrl: String, client: HttpC
client.wss("ws" + baseUrl.replaceFirst("http", "") + "streaming?i=${auth.token}") {
awaitAll(
coroutineScope.async {
commands.onEach { println("Sending :$it");outgoing.send(Frame.Text(it)) }
commands.onEach { Logger.debug("Api Client Streaming","Sending :$it");outgoing.send(Frame.Text(it)) }
.launchIn(coroutineScope)
},
coroutineScope.async {
Expand All @@ -68,7 +69,7 @@ class MisskeyApiClient(var auth: SingleTokenAuth, baseUrl: String, client: HttpC
}
)
}
println("connected")
Logger.debug("Api Client Streaming","Connected")

}
// launch.join()
Expand Down
1 change: 0 additions & 1 deletion impl/misskey/src/test/kotlin/MisskeyTestUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ object MisskeyTestUtil {
): suspend MockRequestHandleScope.(HttpRequestData) -> HttpResponseData {
return { httpRequestData: HttpRequestData ->
val decodeToString = httpRequestData.body.toByteArray().decodeToString()
println(decodeToString)
if ("i" in json.parseToJsonElement(decodeToString).jsonObject) {
respond(respond, status, headers)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ class MetaTestE2E {
@Test
fun meta() = runTest {
val meta = Meta(misskeyApiClient).meta(MetaRequest()).failOnError()
println(meta)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ class NotesTest {

@Test
fun ldttest() {
val parse = Instant.parse("2023-01-17T06:58:08.000Z")
println(parse)
Instant.parse("2023-01-17T06:58:08.000Z")
}


Expand Down Expand Up @@ -198,39 +197,35 @@ class NotesTestE2E {

@Test
fun globalTimeline() = runTest {
val globalTimeline = notes.globalTimeline(NotesGlobalTimelineRequest()).failOnError()
println(globalTimeline)
notes.globalTimeline(NotesGlobalTimelineRequest()).failOnError()
}

@Test
fun hybridTimeline() = runTest {
val hybridTimeline = notes.hybridTimeline(NotesHybridTimelineRequest()).failOnError()
println(hybridTimeline)
notes.hybridTimeline(NotesHybridTimelineRequest()).failOnError()
}

@Test
fun localTimeline() = runTest {
val localTimeline = notes.localTimeline(NotesLocalTimelineRequest()).failOnError()
println(localTimeline)
notes.localTimeline(NotesLocalTimelineRequest()).failOnError()
}

@Test
fun show() = runTest {
val show =
notes.show(NotesShowRequest(notes.notes(NotesNotesRequest()).failOnError().first().id))
.failOnError()
println(show)

}

@Test
fun create() = runTest {
val created = notes.create(
notes.create(
NotesCreateRequest(
visibility = NotesCreateRequest.Visibility.HOME,
text = "このノートはMultim のテストで作成されました。${this@NotesTestE2E::class} create Test"
)
).failOnError()
println(created.createdNote)
}

@Test
Expand Down Expand Up @@ -283,8 +278,7 @@ class NotesTestE2E {

@Test
fun featured() = runTest {
val featured = notes.featured().failOnError()
println(featured)
notes.featured().failOnError()
}

@Test
Expand All @@ -293,7 +287,6 @@ class NotesTestE2E {
notes.create(NotesCreateRequest(text = "このノートはMultiMのテストで作成され、子ノート取得のテストで使用されます。${this@NotesTestE2E::class} children"))
val id = create.failOnError().createdNote.id
val children = notes.children(NotesChildrenRequest(id)).failOnError()
println(children)
}

@Test
Expand All @@ -303,14 +296,12 @@ class NotesTestE2E {
.failOnError()
val conversation =
notes.conversation(NotesConversationRequest(create.createdNote.id)).failOnError()
println(conversation)
}

@Test
fun state() = runTest {
val create = notes.create(NotesCreateRequest(text="このノートはMultiMのテストで作成され、ノートの状態を取得するテストで使用されます。 ${this@NotesTestE2E::class} state")).failOnError()
val state = notes.state(NotesStateRequest(create.createdNote.id)).failOnError()
println(state)
}

@Test
Expand Down Expand Up @@ -346,14 +337,12 @@ class NotesTestE2E {
@Test
fun mentions() = runTest {
val mentions = notes.mentions(NotesMentionsRequest()).failOnError()
println(mentions)
}

@Test
fun reactions() = runTest {
val create = notes.create(NotesCreateRequest(text = "このノートはMultiMのテストで作成され、リアクション取得のテストで使用されます。 ${this@NotesTestE2E::class} reactions")).failOnError()
val reactions = notes.reactions(NotesReactionsRequest(create.createdNote.id))
println(reactions)
}

@Test
Expand All @@ -366,7 +355,6 @@ class NotesTestE2E {
val renotes = NotesRenoteRequest(create.createdNote.id)
.let { notes.renotes(it) }.failOnError()
assertEquals(listOf(notesCreateResponse.createdNote), renotes)
println(renotes)
}

@Test
Expand Down Expand Up @@ -402,7 +390,6 @@ class NotesTestE2E {
val searchByTag = notes.searchByTag(NotesSearchByTagRequest(tag)).failOnError()
org.assertj.core.api.Assertions.assertThat(searchByTag)?.isNotEmpty
assertTrue(searchByTag.contains(tagedNote.createdNote))
println(searchByTag)
}

@Test
Expand Down Expand Up @@ -443,7 +430,6 @@ class NotesTestE2E {
@Test
fun timeline() = runTest {
val timeline = notes.timeline(NotesTimelineRequest()).failOnError()
println(timeline)
}

@RepeatedIfExceptionsTest(repeats = 4)
Expand All @@ -470,10 +456,7 @@ class NotesTestE2E {
@Disabled("リスト操作系のAPIが未実装なため無効化")
// TODO: リスト操作系のAPI追加後、リストを取得してテストするように
fun userListTimeline() = runTest {

val userListTimeline = notes.userListTimeline(NotesUserListTimelineRequest("9ady10e6z5"))
println(userListTimeline)

}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.usbharu.multim.misskey.v12.common.api

import MisskeyTestUtil
import com.github.michaelbull.result.get
import dev.usbharu.multim.TestUtil.failOnError
import dev.usbharu.multim.misskey.v12.api.MisskeyApis
import dev.usbharu.multim.misskey.v12.common.MisskeyStatusId
import dev.usbharu.multim.model.SingleTokenAuth
Expand Down Expand Up @@ -52,7 +53,7 @@ class MisskeyStatusApiTest {
@Test
fun findByIdTest() = runTest {
val findById =
misskeyStatusApi.findById(MisskeyStatusId("9a65528e5z", "https://lcalhost")).get()
println(findById?.content?.text)
misskeyStatusApi.findById(MisskeyStatusId("9a65528e5z", "https://lcalhost")).failOnError()

}
}