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
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ subprojects {
val ktor_version = "2.2.2"
dependencies {
"implementation"("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
"implementation"("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
"api"("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
"implementation"("io.ktor:ktor-client-core:$ktor_version")
"implementation"("io.ktor:ktor-client-cio:$ktor_version")
"implementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
Expand All @@ -109,7 +109,7 @@ subprojects {
"implementation"("io.ktor:ktor-serialization-kotlinx-json:$ktor_version")
"implementation"("dev.usbharu:kmp-logger:1.1.1")
"implementation"("dev.usbharu:emoji-kt:1.1.1")
"implementation"("com.michael-bull.kotlin-result:kotlin-result:1.1.16")
"api"("com.michael-bull.kotlin-result:kotlin-result:1.1.16")
"implementation"("io.github.reactivecircus.cache4k:cache4k:0.9.0")

"testImplementation"("org.junit.jupiter:junit-jupiter-api:5.9.0")
Expand Down
3 changes: 2 additions & 1 deletion impl/misskey/src/test/kotlin/MisskeyTestUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import kotlinx.serialization.json.jsonObject
import org.assertj.core.api.Fail
import org.junit.jupiter.api.Assertions

@Suppress("EmptyIfBlock")
object MisskeyTestUtil {

val json = Json { ignoreUnknownKeys = true;isLenient = true }

val baseUrl = "https://localhsot/"
const val baseUrl = "https://localhsot/"

internal fun apiClient(httpClient: HttpClient): MisskeyApiClient {
return MisskeyApiClient(SingleTokenAuth("cdgj2h71"), baseUrl, httpClient)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ class MisskeyApiClientTest : ApiClientTest() {
}

post_request_returnOkWithEchoBody -> {
respond(it.body.toByteArray().decodeToString(), HttpStatusCode.OK, headersOf(HttpHeaders.ContentType,"application/json"))
respond(
it.body.toByteArray().decodeToString(),
HttpStatusCode.OK,
headersOf(HttpHeaders.ContentType, "application/json")
)
}

post_IllegalRequest_returnErr -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ApTest {
}


@Suppress("LongMethod")
@Test
fun show_userUrl_returnUser() = runTest {
val userDetailedNotMe = UserDetailedNotMe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ package dev.usbharu.multim.misskey.v12.api

import kotlinx.coroutines.*
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test

@OptIn(ExperimentalCoroutinesApi::class)
class MiauthTest {

@OptIn(ExperimentalCoroutinesApi::class)
@Test
@Disabled
fun auth() = runTest {
// println(Miauth("","http://localhost",TestUtil.createMockHttpClient()).auth())
}

@Test
@Disabled
fun check() = runTest {
// val check =
// Miauth("","http://localhost", TestUtil.createMockHttpClient(content = Json.encodeToString(MiauthCheckResponse(ok = true)))).check(MiauthCheckRequest(sessionId = UUID.generateUUID()))
// assertTrue(check.ok)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class NotesTest {
Instant.parse("2023-01-17T06:58:08.000Z")
}


@Suppress("MaxLineLength")
private val expectNoteArray = listOf(
createFakeNote(
"4wT4lSP",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class NotesTestE2E {
val notesCreateResponse = notes.create(
NotesCreateRequest(
visibility = NotesCreateRequest.Visibility.FOLLOWERS,
text = "このノートはMultiMのテストで作成され、公開範囲 フォロワーのみ のテストに使用されます。" + " ${this@NotesTestE2E::class} create note with followers only"
text = "このノートはMultiMのテストで作成され、公開範囲 フォロワーのみ のテストに使用されます。" +
" ${this@NotesTestE2E::class} create note with followers only"
)
).failOnError()
Assertions.assertEquals("followers", notesCreateResponse.createdNote.visibility)
Expand Down Expand Up @@ -198,17 +199,25 @@ class NotesTestE2E {
@Test
fun reactions() = runTest {
val create =
notes.create(NotesCreateRequest(text = "このノートはMultiMのテストで作成され、" +
"リアクション取得のテストで使用されます。 ${this@NotesTestE2E::class} reactions"))
notes.create(
NotesCreateRequest(
text = "このノートはMultiMのテストで作成され、" +
"リアクション取得のテストで使用されます。 ${this@NotesTestE2E::class} reactions"
)
)
.failOnError()
val reactions = notes.reactions(NotesReactionsRequest(create.createdNote.id))
}

@Test
fun renotes() = runTest {
val create =
notes.create(NotesCreateRequest(text = "このノートはMultim のテストで作成され、" +
"リノートのテストで使用されます。 ${this@NotesTestE2E::class} renotes test"))
notes.create(
NotesCreateRequest(
text = "このノートはMultim のテストで作成され、" +
"リノートのテストで使用されます。 ${this@NotesTestE2E::class} renotes test"
)
)
.failOnError()
val notesCreateResponse = notes.create(NotesCreateRequest(renoteId = create.createdNote.id)).failOnError()
val renotes = NotesRenoteRequest(create.createdNote.id).let { notes.renotes(it) }.failOnError()
Expand All @@ -218,8 +227,12 @@ class NotesTestE2E {
@Test
fun replies() = runTest {
val root =
notes.create(NotesCreateRequest(text = "このノートはMultim のテストで作成され、" +
"返信取得のテストで使用されます。 ${this@NotesTestE2E::class} replies test"))
notes.create(
NotesCreateRequest(
text = "このノートはMultim のテストで作成され、" +
"返信取得のテストで使用されます。 ${this@NotesTestE2E::class} replies test"
)
)
.failOnError()
val reply1 = notes.create(
NotesCreateRequest(
Expand All @@ -243,8 +256,12 @@ class NotesTestE2E {
fun searchByTag() = runTest {
val tag = UUID.randomUUID().toString()
val tagedNote =
notes.create(NotesCreateRequest(text = "#$tag このノートはMultimのテストで作成され、" +
"タグ検索のテストで使用されます。 ${this@NotesTestE2E::class} search by tag test"))
notes.create(
NotesCreateRequest(
text = "#$tag このノートはMultimのテストで作成され、" +
"タグ検索のテストで使用されます。 ${this@NotesTestE2E::class} search by tag test"
)
)
.failOnError()
val searchByTag = notes.searchByTag(NotesSearchByTagRequest(tag)).failOnError()
org.assertj.core.api.Assertions.assertThat(searchByTag)?.isNotEmpty
Expand All @@ -254,7 +271,12 @@ class NotesTestE2E {
@Test
fun threadMutingCreate() = runTest {
val create =
notes.create(NotesCreateRequest(text = "このノートはMultimのテストで作成され、スレッドミュートのテストで使用されます。 ${this@NotesTestE2E::class} thread mute create test"))
notes.create(
NotesCreateRequest(
text = "このノートはMultimのテストで作成され、スレッドミュートのテストで使用されます。 " +
"${this@NotesTestE2E::class} thread mute create test"
)
)
.failOnError()
Assertions.assertFalse(NotesStateRequest(create.createdNote.id).let {
notes.state(it).failOnError().isMutedThread
Expand All @@ -268,7 +290,12 @@ class NotesTestE2E {
@Test
fun threadMutingDelete() = runTest {
val create =
notes.create(NotesCreateRequest(text = "このノートはMultimのテストで作成され、スレッドミュート解除のテストで使用されます。 ${this@NotesTestE2E::class} thread mute delete test"))
notes.create(
NotesCreateRequest(
text = "このノートはMultimのテストで作成され、スレッドミュート解除のテストで使用されます。 " +
"${this@NotesTestE2E::class} thread mute delete test"
)
)
.failOnError()
Assertions.assertFalse(
notes.state(NotesStateRequest(create.createdNote.id)).failOnError().isMutedThread
Expand All @@ -292,7 +319,12 @@ class NotesTestE2E {
// @Test
fun unrenote() = runBlocking {
val create =
notes.create(NotesCreateRequest(text = "このノートはMultimのテストで作成され、リノート取り消しのテストで使用されます。 ${this@NotesTestE2E::class} unrenote test"))
notes.create(
NotesCreateRequest(
text = "このノートはMultimのテストで作成され、リノート取り消しのテストで使用されます。" +
" ${this@NotesTestE2E::class} unrenote test"
)
)
.failOnError()
delay(1000)
val renoted = notes.create(NotesCreateRequest(renoteId = create.createdNote.id)).failOnError()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.util.*

@Suppress("EmptyFunctionBlock")
class TimelineTestE2E {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.fail

@Suppress("EmptyIfBlock")
@OptIn(ExperimentalCoroutinesApi::class)
class MisskeyAccountApiTest : AccountApiTest() {
override val accountApi: AccountApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class MisskeyStatusApiTest {
data class Hoge(val a: String, val b: String)

//language=JSON
val hoge: Hoge = Json(Json.Default) {
Json(Json.Default) {
isLenient = true;ignoreUnknownKeys = true
}.decodeFromString("""{"a": "aaaa","b": "bbbb"}""")
}.decodeFromString<Hoge>("""{"a": "aaaa","b": "bbbb"}""")
}

@OptIn(ExperimentalCoroutinesApi::class)
Expand Down