Added getting Pinboard API token from (CircleCI) environment variable.

This commit is contained in:
Erik C. Thauvin 2017-11-04 00:21:24 -07:00
parent 1cfda5f72b
commit 1d36d78bf4
2 changed files with 21 additions and 8 deletions

View file

@ -34,15 +34,22 @@ package net.thauvin.erik.pinboard
import org.testng.Assert
import org.testng.annotations.Test
import java.io.FileInputStream
import java.util.*
import java.nio.file.Files
import java.nio.file.Paths
import java.util.Properties
class PinboardPosterTest {
private val url = "http://www.foo.com/"
private val desc = "This is a test."
private val p = Properties().apply { FileInputStream("local.properties").use { fis -> load(fis) } }
private val apiToken = p.getProperty("pinboard-api-token")
@Test
private val localProps = Paths.get("local.properties")
private val apiToken = if (Files.exists(localProps)) {
val p = Properties().apply { Files.newInputStream(localProps).use { fis -> load(fis) }}
p.getProperty("pinboard-api-token", "")
} else {
System.getenv("PINBOARD_API_TOKEN")
}
@Test
fun testAddPin() {
val poster = PinboardPoster("")
@ -70,4 +77,4 @@ class PinboardPosterTest {
Assert.assertFalse(poster.deletePin("foo.com"), "url: foo.com")
}
}
}