Skip to content

Commit 8dde594

Browse files
committed
Drop file_size default in AttachmentDto and test null mapping
1 parent e55ca23 commit 8dde594

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
@@ -746,7 +746,7 @@ internal object Mother {
746746
authorName: String? = randomString(),
747747
authorLink: String? = randomString(),
748748
fallback: String? = randomString(),
749-
fileSize: Int = positiveRandomInt(),
749+
fileSize: Int? = positiveRandomInt(),
750750
image: String? = randomString(),
751751
imageUrl: String? = randomString(),
752752
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
@@ -568,6 +568,16 @@ internal class DomainMappingTest {
568568
assertEquals(expected, attachment)
569569
}
570570

571+
@Test
572+
fun `AttachmentDto with null file_size falls back to 0`() {
573+
val attachmentDto = randomAttachmentDto(fileSize = null)
574+
val sut = Fixture().get()
575+
val attachment = with(sut) {
576+
attachmentDto.toDomain()
577+
}
578+
assertEquals(0, attachment.fileSize)
579+
}
580+
571581
@Test
572582
fun `BannedUserResponse is correctly mapped to BannedUser`() {
573583
val bannedUserResponse = randomBannedUserResponse()

0 commit comments

Comments
 (0)