Restructed with Bilinks, Constants, and Utils classes.
This commit is contained in:
parent
6e1240e38b
commit
d77b3cce72
8 changed files with 366 additions and 233 deletions
|
@ -51,7 +51,7 @@ class BitlyTest {
|
|||
|
||||
@Before
|
||||
fun before() {
|
||||
with(bitly.logger) {
|
||||
with(Utils.logger) {
|
||||
level = Level.FINE
|
||||
}
|
||||
}
|
||||
|
@ -62,33 +62,33 @@ class BitlyTest {
|
|||
if (System.getenv("CI") == "true") {
|
||||
test.accessToken = ""
|
||||
}
|
||||
assertEquals("", test.shorten(blog))
|
||||
assertEquals("", test.bitlinks().shorten(blog))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `token should be valid`() {
|
||||
val test = Bitly().apply { accessToken = "12345679" }
|
||||
assertEquals("{\"message\":\"FORBIDDEN\"}", test.shorten("https://erik.thauvin.net/blog", isJson = true))
|
||||
assertEquals("{\"message\":\"FORBIDDEN\"}", test.bitlinks().shorten("https://erik.thauvin.net/blog", isJson = true))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `long url should be valid`() {
|
||||
assertEquals("", bitly.shorten(""))
|
||||
assertEquals("", bitly.bitlinks().shorten(""))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `shorten = expand`() {
|
||||
val shortUrl = bitly.shorten(blog, domain = "bit.ly")
|
||||
assertEquals(blog, bitly.expand(shortUrl))
|
||||
val shortUrl = bitly.bitlinks().shorten(blog, domain = "bit.ly")
|
||||
assertEquals(blog, bitly.bitlinks().expand(shortUrl))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `as json`() {
|
||||
assertTrue(bitly.shorten(blog, isJson = true).startsWith("{\"created_at\":"))
|
||||
assertTrue(bitly.bitlinks().shorten(blog, isJson = true).startsWith("{\"created_at\":"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `get user`() {
|
||||
assertTrue(bitly.call(bitly.buildEndPointUrl("user"), emptyMap(), Methods.GET).contains("\"login\":"))
|
||||
assertTrue(bitly.call(Utils.buildEndPointUrl("user"), emptyMap(), Methods.GET).contains("\"login\":"))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue