From cc22174e64f6fa502a8e2993498f373927193e05 Mon Sep 17 00:00:00 2001 From: Eritque arcus Date: Sat, 18 Feb 2023 15:32:21 -0500 Subject: [PATCH] [mock] add size into MockImage (#2515) --- mirai-core-mock/src/internal/MockBotImpl.kt | 7 ++++++- mirai-core-mock/test/ImageUploadTest.kt | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mirai-core-mock/src/internal/MockBotImpl.kt b/mirai-core-mock/src/internal/MockBotImpl.kt index df36f7956c..0e7e67fe15 100644 --- a/mirai-core-mock/src/internal/MockBotImpl.kt +++ b/mirai-core-mock/src/internal/MockBotImpl.kt @@ -185,7 +185,12 @@ internal class MockBotImpl( val md5 = resource.md5 val format = resource.formatName - return MockImage(generateImageId(md5, format), bot.tmpResourceServer.uploadResourceAsImage(resource).toString()) + // todo width, height ? + return MockImage( + imageId = generateImageId(md5, format), + urlPath = bot.tmpResourceServer.uploadResourceAsImage(resource).toString(), + size = resource.size + ) } override fun toString(): String { diff --git a/mirai-core-mock/test/ImageUploadTest.kt b/mirai-core-mock/test/ImageUploadTest.kt index ab0aeaf6f9..fb4bd8f75b 100644 --- a/mirai-core-mock/test/ImageUploadTest.kt +++ b/mirai-core-mock/test/ImageUploadTest.kt @@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance import java.net.URL import kotlin.test.assertEquals +import kotlin.test.assertNotEquals import kotlin.test.assertTrue @TestInstance(TestInstance.Lifecycle.PER_METHOD) @@ -44,6 +45,7 @@ internal class ImageUploadTest { assertTrue { data.contentEquals(URL(img.queryUrl()).readBytes()) } + assertNotEquals(0, img.size) } @Test