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
5 changes: 1 addition & 4 deletions src/main/kotlin/dev/usbharu/multim/api/common/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ abstract class ApiClient(var baseUrl: String, val client: HttpClient) {
contentType(ContentType.Application.Json)
setBody(content)
}
println("post = $post")
println(post.toString())
println(post.status.value)
println(post.content.toByteArray().toString())

return post.body()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlinx.serialization.json.Json
@OptIn(InternalAPI::class)
class MisskeyApiClient(var token: String, baseUrl: String, client: HttpClient) :
ApiClient(baseUrl, client.config {
expectSuccess = true
install(WebSockets) {
pingInterval = 20_000
}
Expand Down
43 changes: 31 additions & 12 deletions src/test/kotlin/dev/usbharu/multim/api/misskey/v12/NotesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import dev.usbharu.multim.api.common.createHttpClient
import dev.usbharu.multim.model.misskey.v12.*
import io.ktor.client.*
import io.ktor.client.engine.mock.*
import io.ktor.client.plugins.*
import io.ktor.http.*
import io.ktor.utils.io.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand All @@ -15,6 +16,7 @@ import kotlinx.datetime.Instant
import kotlinx.serialization.encodeToString
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows

@OptIn(ExperimentalCoroutinesApi::class)
class NotesTest {
Expand All @@ -25,7 +27,10 @@ class NotesTest {
MisskeyApiClient(
"aaaa",
"",
TestUtil.createMockHttpClient(checkAuth = false, content = json.encodeToString(expectNoteArray))
TestUtil.createMockHttpClient(
checkAuth = false,
content = json.encodeToString(expectNoteArray)
)
)
)
val globalTimeline =
Expand All @@ -52,7 +57,10 @@ class NotesTest {
MisskeyApiClient(
"aaa",
"",
TestUtil.createMockHttpClient(checkAuth = false, content = json.encodeToString(expectNoteArray))
TestUtil.createMockHttpClient(
checkAuth = false,
content = json.encodeToString(expectNoteArray)
)
)
)
val localTimeline = notes.localTimeline(NotesLocalTimelineRequest())
Expand All @@ -66,7 +74,10 @@ class NotesTest {
MisskeyApiClient(
"aaa",
"",
TestUtil.createMockHttpClient(checkAuth = false, content = json.encodeToString(expectedNote))
TestUtil.createMockHttpClient(
checkAuth = false,
content = json.encodeToString(expectedNote)
)
)
)
val note = notes.show(NotesShowRequest("mLvakn"))
Expand Down Expand Up @@ -166,7 +177,13 @@ class NotesTest {

class NotesTestE2E {

val notes = Notes(MisskeyApiClient(System.getProperty("multim_misskey_token"), "https://misskey.usbharu.dev/", createHttpClient()))
val notes = Notes(
MisskeyApiClient(
System.getProperty("multim_misskey_token"),
"https://misskey.usbharu.dev/",
createHttpClient()
)
)

@Test
fun globalTimeline() = runTest {
Expand Down Expand Up @@ -212,14 +229,16 @@ class NotesTestE2E {
)
)
notes.delete(NotesDeleteRequest(deleteNote.createdNote.id))
notes.show(NotesShowRequest(deleteNote.createdNote.id)) //消せていたら失敗する
}
assertThrows<ClientRequestException> {
notes.show(NotesShowRequest(deleteNote.createdNote.id)) //消せていたら失敗する
}
}

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


}
}