Skip to content

Commit 0d5b3b8

Browse files
committed
Fix comment endpoint api
1 parent 6595a07 commit 0d5b3b8

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

library/src/main/kotlin/me/proxer/library/api/comment/UpdateCommentEndpoint.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class UpdateCommentEndpoint internal constructor(
4141
* Sets the rating for the comment. Must be between 0 and 10, while 0 means no rating is given by the user.
4242
*/
4343
fun rating(rating: Int?): UpdateCommentEndpoint {
44-
require(rating in 0..10) {
44+
require(rating == null || rating in 0..10) {
4545
"The rating must be between 0 and 10."
4646
}
4747

@@ -65,7 +65,7 @@ class UpdateCommentEndpoint internal constructor(
6565
/**
6666
* Sets the content of the comment. May contain BBCode tags and can be empty.
6767
*/
68-
fun comment(comment: String): UpdateCommentEndpoint {
68+
fun comment(comment: String?): UpdateCommentEndpoint {
6969
return this.apply { this.comment = comment }
7070
}
7171

library/src/test/kotlin/me/proxer/library/api/comment/UpdateCommentEndpointTest.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import me.proxer.library.runRequest
66
import org.amshove.kluent.invoking
77
import org.amshove.kluent.shouldBeNull
88
import org.amshove.kluent.shouldEqual
9+
import org.amshove.kluent.shouldNotThrow
910
import org.amshove.kluent.shouldThrow
1011
import org.junit.jupiter.api.Test
1112
import org.junit.jupiter.params.ParameterizedTest
@@ -127,4 +128,11 @@ class UpdateCommentEndpointTest : ProxerTest() {
127128
api.comment.update("0").rating(rating)
128129
} shouldThrow IllegalArgumentException::class
129130
}
131+
132+
@Test
133+
fun testRatingValidationNull() {
134+
invoking {
135+
api.comment.update("0").rating(null)
136+
} shouldNotThrow IllegalArgumentException::class
137+
}
130138
}

0 commit comments

Comments
 (0)