Closed book000 closed 3 months ago
Replacerのテストもう少し作り込まなきゃダメかな…
さて、結合テストのバターンを考えないと…。
Attachment.downloadがですとできないやつ、HttpClient.getをmockすればいいのか?
画像ファイルの文字起こし処理テストに断念。とりあえずメモ message.replyがinlineなことにより、モックできないらしい
test("download") {
// 画像ファイル image.png
mockkStatic("com.kotlindiscord.kord.extensions.utils._AttachmentsKt")
val attachment = mockk<Attachment>()
every { attachment.isImage } returns true
every { attachment.isSpoiler } returns false
every { attachment.filename } returns "image.png"
coEvery { attachment.download() } returns byteArrayOf(0x00)
// VisionApi
mockkObject(VisionApi)
every { VisionApi.isGoogleAppCredentialsExist() } returns true
every { VisionApi.getTextAnnotations(any()) } returns listOf(
VisionTextAnnotation(
"test",
"ja",
1.0f,
listOf(VisionVertex(0, 0), VisionVertex(0, 0), VisionVertex(0, 0), VisionVertex(0, 0))
)
)
every { VisionApi.drawTextAnnotations(any()) } returns mockk<ImmutableImage> {
every { output(any<PngWriter>(), any<File>()) } returns mockk()
}
mockkObject(VCSpeaker)
every { VCSpeaker.storeFolder } returns File("./store-test")
mockkObject(VisionApiCounterStore)
every { VisionApiCounterStore.get() } returns mockk {
every { count } returns 0
}
every { VisionApiCounterStore.increment() } just Runs
mockkStatic("dev.kord.core.behavior.MessageBehaviorKt")
val message = mockk<Message>()
coEvery { message.reply(any()) } returns mockk<Message>()
every { message.attachments } returns setOf(attachment)
val voice = Voice(speaker = Speaker.Hikari)
val (processedText, processedVoice) = AttachmentProcessor().process(message, "test", voice)
processedText shouldBe "test 画像ファイル image.png "
processedVoice shouldBe voice
}
@yuuahp レビューをお願いします。基本的にはテストの追加ばっかりですが、PRあたりの変更がかなり大きくなってしまいごめんなさい
それはそれとして、assign reviewは相変わらずエラーです https://github.com/jaoafa/VCSpeaker.kt/actions/runs/9632849766/job/26566534103
もしかしてコミットされるとその部分のレビューのドラフト消える?
うそお!?
発話そのものの可否と、メッセージメタデータを使う処理、VoiceTextパラメータの変更を必要とする機能である Processor を Replacer 同様に分割し、processText関数内でのごちゃごちゃを軽減させます。
テストケース名レビュー: https://docs.google.com/spreadsheets/d/13ofOk0xV5aIzA8RJHYRaUE1Bhf84VuaBigPSb2EXhKI/edit?usp=sharing
進捗
テストケースの整理
Markdown Heading の読み上げ音量変更 (h1: 200%, h2: 175%, h3: 150%)#155