Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmine DiMascio committed Nov 12, 2018
1 parent b54bd75 commit e2da613
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/io/github/cdimascio/dotenv/Dotenv.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ abstract class Dotenv {
operator abstract fun get(envVar: String): String?
}

/**
* Dotenv exception
*/
class DotEnvException(message: String) : Exception(message)

/**
Expand Down
32 changes: 16 additions & 16 deletions src/test/kotlin/tests/BasicTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import kotlin.test.assertEquals
import kotlin.test.assertNull
import org.junit.Test as test

class DotEnvTest() {
class DotEnvTest {
private val envVars = mapOf(
"MY_TEST_EV1" to "my test ev 1",
"MY_TEST_EV2" to "my test ev 2"
"MY_TEST_EV1" to "my test ev 1",
"MY_TEST_EV2" to "my test ev 2"
)

@test(expected = DotEnvException::class)

fun dotenvMalformed() {
Dotenv.configure()
.directory("./src/test/resources")
.load()
.directory("./src/test/resources")
.load()
}

@test
Expand Down Expand Up @@ -60,9 +60,9 @@ class DotEnvTest() {
@test
fun resourceRelative() {
val dotenv = Dotenv.configure()
.directory("./")
.ignoreIfMalformed()
.load()
.directory("./")
.ignoreIfMalformed()
.load()
assertEquals("my test ev 1", dotenv["MY_TEST_EV1"])

val expectedHome = System.getProperty("user.home")
Expand All @@ -73,8 +73,8 @@ class DotEnvTest() {
@test
fun resourceCurrent() {
val dotenv = Dotenv.configure()
.ignoreIfMalformed()
.load()
.ignoreIfMalformed()
.load()
assertEquals("my test ev 1", dotenv["MY_TEST_EV1"])

val expectedHome = System.getProperty("user.home")
Expand All @@ -85,21 +85,21 @@ class DotEnvTest() {
@test(expected = DotEnvException::class)
fun dotenvMissing() {
Dotenv.configure()
.directory("/missing/.env")
.load()
.directory("/missing/.env")
.load()
}

@test
fun dotenvIgnoreMissing() {
val dotenv = Dotenv.configure()
.directory("/missing/.env")
.ignoreIfMissing()
.load()
.directory("/missing/.env")
.ignoreIfMissing()
.load()

val expectedHome = System.getProperty("user.home")
val actualHome = dotenv.get("HOME")
assertEquals(expectedHome, actualHome)

assertNull(dotenv["MY_TEST_EV1"])
}
}
}
4 changes: 2 additions & 2 deletions src/test/kotlin/tests/DslTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import kotlin.test.assertEquals
import kotlin.test.assertNull
import org.junit.Test as test

class DotEnvDslTest() {
class DotEnvDslTest {
private val envVars = mapOf(
"MY_TEST_EV1" to "my test ev 1",
"MY_TEST_EV2" to "my test ev 2"
Expand Down Expand Up @@ -91,4 +91,4 @@ class DotEnvDslTest() {
assertEquals(expectedHome, actualHome)
assertNull(env["MY_TEST_EV1"])
}
}
}

0 comments on commit e2da613

Please sign in to comment.