Skip to content

Commit 1f5b237

Browse files
committed
Drop file_size default in AttachmentDto and test null mapping
1 parent 7515acc commit 1f5b237

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/AttachmentDto.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal data class AttachmentDto(
3333
val author_name: String?,
3434
val author_link: String?,
3535
val fallback: String?,
36-
val file_size: Int? = 0,
36+
val file_size: Int?,
3737
val image: String?,
3838
val image_url: String?,
3939
val mime_type: String?,

stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ internal object Mother {
750750
authorName: String? = randomString(),
751751
authorLink: String? = randomString(),
752752
fallback: String? = randomString(),
753-
fileSize: Int = positiveRandomInt(),
753+
fileSize: Int? = positiveRandomInt(),
754754
image: String? = randomString(),
755755
imageUrl: String? = randomString(),
756756
mimeType: String? = randomString(),

stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/DomainMappingTest.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,16 @@ internal class DomainMappingTest {
576576
assertEquals(expected, attachment)
577577
}
578578

579+
@Test
580+
fun `AttachmentDto with null file_size falls back to 0`() {
581+
val attachmentDto = randomAttachmentDto(fileSize = null)
582+
val sut = Fixture().get()
583+
val attachment = with(sut) {
584+
attachmentDto.toDomain()
585+
}
586+
assertEquals(0, attachment.fileSize)
587+
}
588+
579589
@Test
580590
fun `BannedUserResponse is correctly mapped to BannedUser`() {
581591
val bannedUserResponse = randomBannedUserResponse()

0 commit comments

Comments
 (0)