Fix incorrectly incrementing IDs before sending to server. (#1026)

* Fix incorrectly incrementing IDs before sending to server.

* Add TimelineRepositoryTest, fix adding placeholder, fix String#dec()

* Add more TimelineRepository tests, fix bugs

* Add tests for adding statuses from DB.
This commit is contained in:
Ivan Kupalov 2019-02-05 20:06:00 +01:00 committed by Konrad Pozniak
commit 63952813c8
11 changed files with 631 additions and 208 deletions

View file

@ -1,6 +1,7 @@
package com.keylesspalace.tusky
import com.keylesspalace.tusky.util.dec
import com.keylesspalace.tusky.util.inc
import com.keylesspalace.tusky.util.isLessThan
import org.junit.Assert.*
import org.junit.Test
@ -11,7 +12,8 @@ class StringUtilsTest {
val lessList = listOf(
"abc" to "bcd",
"ab" to "abc",
"cb" to "abc"
"cb" to "abc",
"1" to "2"
)
lessList.forEach { (l, r) -> assertTrue("$l < $r", l.isLessThan(r)) }
val notLessList = lessList.map { (l, r) -> r to l } + listOf(
@ -20,6 +22,15 @@ class StringUtilsTest {
notLessList.forEach { (l, r) -> assertFalse("not $l < $r", l.isLessThan(r)) }
}
@Test
fun inc() {
listOf(
"122" to "123",
"12A" to "12B",
"1" to "2"
).forEach { (l, r) -> assertEquals("$l + 1 = $r", r, l.inc()) }
}
@Test
fun dec() {
listOf(
@ -28,7 +39,8 @@ class StringUtilsTest {
"120" to "11z",
"100" to "zz",
"0" to "",
"" to ""
"" to "",
"2" to "1"
).forEach { (l, r) -> assertEquals("$l - 1 = $r", r, l.dec()) }
}
}