Added CallResponse and Bitlinks.update().

This commit is contained in:
Erik C. Thauvin 2020-03-03 13:34:32 -08:00
parent 9ba23fd6c3
commit 318409cb2f
7 changed files with 155 additions and 19 deletions

View file

@ -34,7 +34,6 @@ package net.thauvin.erik.bitly
import net.thauvin.erik.bitly.Utils.Companion.removeHttp
import net.thauvin.erik.bitly.Utils.Companion.toEndPoint
import org.json.JSONObject
import org.junit.Before
import java.io.File
import java.util.logging.Level
@ -97,16 +96,16 @@ class BitlyTest {
@Test
fun `get user`() {
assertTrue(bitly.call("/user".toEndPoint(), method = Methods.GET).contains("\"login\":"))
assertTrue(bitly.call("/user".toEndPoint(), method = Methods.GET).isSuccessful)
}
@Test
fun `created by`() {
assertEquals(
"ethauvin",
JSONObject(
bitly.call("/bitlinks/${shortUrl.removeHttp()}".toEndPoint(), method = Methods.GET)
).getString("created_by")
bitly.call("/bitlinks/${shortUrl.removeHttp()}".toEndPoint(), method = Methods.GET)
.toJson()
.getString("created_by")
)
}
@ -138,4 +137,12 @@ class BitlyTest {
)
)
}
@Test
fun `update bitlink`() {
assertEquals(
true.toString(),
bitly.bitlinks().update(shortUrl, title = "Erik's Weblog", tags = arrayOf("blog", "weblog"))
)
}
}