From 1d36d78bf404683cc9a82b254968b950b5330f56 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sat, 4 Nov 2017 00:21:24 -0700 Subject: [PATCH] Added getting Pinboard API token from (CircleCI) environment variable. --- .circleci/config.yml | 10 ++++++++-- .../erik/pinboard/PinboardPosterTest.kt | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dffffe6..8689e94 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,5 +27,11 @@ jobs: key: kobalt-dependencies-{{ checksum "kobalt/src/Build.kt" }} - run: - name: Assemble - command: ./kobaltw assemble \ No newline at end of file + name: Assemble & Test + command: ./kobaltw assemble test + + - store_artifacts: + path: kobaltBuild/test-output/ + destination: test-output + - store_test_results: + path: kobaltBuild/test-output/ diff --git a/src/test/kotlin/net/thauvin/erik/pinboard/PinboardPosterTest.kt b/src/test/kotlin/net/thauvin/erik/pinboard/PinboardPosterTest.kt index 8349463..37b1581 100644 --- a/src/test/kotlin/net/thauvin/erik/pinboard/PinboardPosterTest.kt +++ b/src/test/kotlin/net/thauvin/erik/pinboard/PinboardPosterTest.kt @@ -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") } -} \ No newline at end of file +}