Skip to content

Commit

Permalink
[mock] add size into MockImage (#2515)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nambers committed Feb 18, 2023
1 parent 9f36eff commit cc22174
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mirai-core-mock/src/internal/MockBotImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions mirai-core-mock/test/ImageUploadTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -44,6 +45,7 @@ internal class ImageUploadTest {
assertTrue {
data.contentEquals(URL(img.queryUrl()).readBytes())
}
assertNotEquals(0, img.size)
}

@Test
Expand Down

0 comments on commit cc22174

Please sign in to comment.